Inventory Management - Products quantity in stock

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • samuel
    Junior Member
    • Jul 2017
    • 6

    Inventory Management - Products quantity in stock

    EspoCRM are really powerful. Thanks a lot, but some question left yet and I can't find solution in existing topics.
    I need to have Inventory management with remains of products in stoke.
    So when some product is sold this quantity going minus and somehow I would fulfill this quantity.
    I understand that this is not so much belongs to CRM but it will be better to have everything in one place.
    So I was thinking about creating entities and properties to have Stock and quantity, but how to develop functionality which will provide quantity management I don't know.
    May be there is some extension also for that, but I can't find it.
    There is Invoicing in Advanced package, but there is no quantity management.
    I would like to see how many products I have in Stock and be able to manage this quantity by selling products and purchasing them.

    Thanks in advance.
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Hi,

    It's possible to implement via Workflow indeed.


    1. You need to have quantity field of int type in Product entity.
    2. Create a Workflow Rule for Quote Item entity "After record created".
    3. On Actions tab select "Update related entity" and select Product.
    4. Specify formula:
    PHP Code:
    quantity = quantity - targetEntity\attribute('quantity') 
    

    But this solution is not perfect. If you remove some quote items it won't re-calculate stock.

    2024 UPDATE

    Now quantity tracking is supported in Sales Pack.​
    Last edited by yuri; 01-17-2024, 09:01 AM.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • samuel
      Junior Member
      • Jul 2017
      • 6

      #3
      Hi yurikuzn, thanks a lot for quick respond.
      Yes, it is working perfectly, I have checked.

      Yes, it is not perfect solution for full control under product quantities, but may be we can have some of the following solutions?
      1. Create a Workflow Rule for "After record saved" and put formula something like this? "quantity = quantity - (targetEntity\attributeAfterUpdate('quantity') - targetEntity\attribute('quantity'))".
      - I can't find full documentation on formulas and don't know if something like "attributeAfterUpdate" exists
      - I found only this Articles about Workflow formulas:
      -- https://github.com/espocrm/documenta...ula-in-actions
      -- https://github.com/espocrm/documenta...ion/formula.md
      - also I have checked on delete record, the "After record saved" is not triggering.
      2. Create new Trigger type "After record deleted", which will be perfect if possible.

      Comment

      • yuri
        Member
        • Mar 2014
        • 8440

        #4
        Hi,

        To get attribute value after update you need just write it's name or entity\attribute('attributeName')
        To get attribute value that was before update you need use entity\attributeFetched('attributeName')
        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

        Comment

        • tanya
          Senior Member
          • Jun 2014
          • 4308

          #5
          Hello
          Trigger type "After record deleted" is not implemented yet and not sure about it will be in the future.
          For this you need to develop a hook 'afterRemove'

          Comment

          • Mark
            Senior Member
            • Dec 2019
            • 143

            #6
            Hi, I have a problem with calculating the stock with formula. What I'm trying to do is substract from the product quantity using Quote Item. So the way I want it to work is:
            1. Add products to Quote (Quote Items) and enter the Qty of the product https://gyazo.com/2ba880b571557f7c35e4adbce2e218fd
            2. This would activate a workflow which substracts the entered Qty from the product quantity, which is in the Product entity https://gyazo.com/cf3140eeb9beb05b97e2f39f0bfd2b0f
            The problem I'm having is with the formula. When I select Add attribute I can see all of the fields from other relationships except for the QuoteItem https://gyazo.com/c401bb03455f944824f82b79c99f607c, which is the one I need. I tried updating the quantity field in the Product entity using "Add field" feature https://gyazo.com/2509e65d3e137c54ef534331e51312ef and it works, but I cannot substract using that feature so it's not an option. I've tried to do this in all kinds of different ways, but it does not seem to work. Maybe I'm missing something? Or I'm not using the formula in the correct way?

            Comment

            • Maximus
              Senior Member
              • Nov 2018
              • 2731

              #7
              Hello Mark,
              I think it is because there is no such relation between Product and Quote Item.
              Try to use the workflow provided on the screenshot.
              Note that the workflow triggers even upon record updating. It was made if you need to increase the quantity after a quote is created. But this logic will not set previous value if you will decrease the quantity after increasing. The same thing if you will remove a quote item from the quote.
              For this you need to use more complex Formula or change a trigger type to 'After record created'.

              Attached Files

              Comment


              • Bashar
                Bashar commented
                Editing a comment
                is it possible to activate the workflow only when the status of the quote is approved?

              • Maximus
                Maximus commented
                Editing a comment
                Hello @Bashar,
                Sure you can set Workflow to be triggered when a record is changed and the Status is equated to 'Approved'.

              • Bashar
                Bashar commented
                Editing a comment
                Hello Maximus,
                thanks a lot for the quick respond.
                how can i do that ?
            • Mark
              Senior Member
              • Dec 2019
              • 143

              #8
              Thank you Maximus, it works now!
              Last edited by Mark; 01-24-2020, 11:55 AM.

              Comment

              • Nishan Perera
                Active Community Member
                • Jan 2019
                • 348

                #9
                Hello,

                I have a small question,

                Can we do multiple orders in espocrm in single purchase request ?
                Cheers!
                Nishan.

                Comment

                • Bashar
                  Junior Member
                  • Feb 2021
                  • 11

                  #10
                  @Maximus,

                  Here i set Workflow to be triggered when a record is changed. But where to triggered only when the Status is equated to 'Approved' ?

                  Comment

                  • Maximus
                    Senior Member
                    • Nov 2018
                    • 2731

                    #11
                    Bashar, you need to set it in the Conditions.

                    Comment

                    • Bashar
                      Junior Member
                      • Feb 2021
                      • 11

                      #12
                      Maximus, it work when i make quote and set the status value direct on 'approved'. But if i make a quote with another status value and change it later to 'approved' then it don't work. also if i set the value direct on 'approved' and the workflow substract the quentity from the broduct and later i change the status again to another value it don't work either

                      Comment

                      • Maximus
                        Senior Member
                        • Nov 2018
                        • 2731

                        #13
                        Hi,
                        1. You created Workflow for the Quote Item entity but want's to trigger it depending on the change in the Quote entity. This Workflow won't work, or will work not properly.
                        If you create a workflow for the Quote Item entity it will listen to events (create, save, change, etc.) not in the Quote entity, but Quote Item entity.
                        In this case you need to create a Sequential Workflow:
                        1) Create a Workflow for the Quote Item with the trigger type: Sequential.
                        2) Create a Workflow for the Quote entity (after record saved) -> add Action -> Trigger Another Workflow Rule (select the first Workflow). Set the desired condition.

                        2. You said that you need to trigger workflow when Status is changed to 'approved'. You said nothing about the condition when 'approved' is changed to another. For the 2-nd condition, you will need to create another workflow because you cannot combine the 1-st and the 2-nd conditions in one Workflow.

                        Comment

                        • Bashar
                          Junior Member
                          • Feb 2021
                          • 11

                          #14
                          Maximus thank you for your patience,
                          this is what i did, but it doesn't work at all now.
                          did I do something wrong?

                          Comment

                          • Maximus
                            Senior Member
                            • Nov 2018
                            • 2731

                            #15
                            Hi Bashar,
                            Previously I was focused on another issue so didn't analyze your Formula. Now I see that you are trying to update the storage stock.
                            I've noticed that you missed the semicolon (";") at the end of the first line of Formula. That's why your formula doesn't work.

                            Please read this https://docs.espocrm.com/administration/formula/#syntax ->
                            Code:
                            Separated expressions must be delimited by character ;.

                            Comment

                            Working...