Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual product stock correction #13368

Closed
futurehousestore opened this issue Mar 16, 2020 · 13 comments
Closed

Virtual product stock correction #13368

futurehousestore opened this issue Mar 16, 2020 · 13 comments
Labels
Bug This is a bug (something does not work as expected)

Comments

@futurehousestore
Copy link
Contributor

Bug

Stock correction of the virtual product has no effect on the parent product. I have attached the video that explains the bug. If the team thinks it's not a bug, please change the label to Feature Request

https://1drv.ms/v/s!AkCF1g4VB-lZhnzpk4fWknnyAlyg

Environment

  • Version: 11.0.2
  • OS: Linux server2.turro.pl 3.14.32-xxxx-grs-ipv6-64 Fix: bad value with multi-company module #7 SMP Wed Jan 27 18:05:09 CET 2016 x86_64
  • Web server: Apache/2
  • PHP: 7.1.33
  • Database: MySQL or MariaDB 5.5.5-10.4.12-MariaDB
  • URL(s): /htdocs/product/stock/product.php

Expected and actual behavior

Actual behaviour: When parent product quantity is changed the child (virtual product) quantity changes which is correct and expected but when child product quantity is changed the parent product quantity do not change.
Expected behaviour: When parent product quantity is changed the child quantity changes and when child product quantity is changed the parent product quantity is changed.

Steps to reproduce the behavior

Create 2 products (parent and child) add the child product to the main product in the virtual products tab input quantity and tick the box "Increase/Decrease stock on parent change". Go to Stock tab of the virtual product and adjust the stock then go to parent product and check the stock quantity.

@futurehousestore futurehousestore added the Bug This is a bug (something does not work as expected) label Mar 16, 2020
@atm-maxime
Copy link
Member

And if the child product is used in several virtual products, what happens ? All parents should be changed ??

@futurehousestore
Copy link
Contributor Author

Thanks, @atm-maxime I haven't thought about this case. It looks like some people may use one virtual product to create more than one product and the actual behaviour of virtual products functionality works for them but it doesn't work for me. Maybe it's not a bug but functionality like that should be added to the actual virtual products (with an option to enable it and disable it) or a new functionality should be created as eg. virtual products 2?
I use virtual products to create sets eg. Set1 which contains 1 x Product1, 1 x Product2, 1 x Product3
I can purchase Set1 but I mainly purchase the components to create the set (Product1, Product2 and Product3) and sell them all as a Set1 and as individual products. To make Set1 I need 1 x Product1, 1 x Product2, 1 x Product3 so if I have 5 x Product1, 5 x Product2, 5 x Product3 then I should have 5 x Set1 but if I sell Product1 on its own then I have 4 x Product1, 5 x Product2, 5 x Product3 and I cannot create 5 x Set1 anymore because of lack of one component. So in my case when the child product is changed the parent product should change as well. I think a better example should explain it better
to create 1 x Set1 we need 4 x Product1, 3 x Product2 and 6 x Product3
In the warehouse, we have 12 x Product1, 9 x Product2 and 18 x Product3 which gives us 3 x Set1
if we sell 1, 2, 3 or 4 units of Product1 then we are unable to create 3 x Set1 anymore. But if we have 12 x Product1, 9 x Product2 and 18 x Product3 which gives us 3 x Set1 and we purchase 2 x Product1 then the Set1 should remian 3 until every product (Product1, Product2 and Product3) incease to meet the criteria to create Set1
A+B+C=D
A = 4 (Product1)
B = 3 (Product2)
C = 6 (Product3)
D = 1 (set of 4 x A + 3 x B + 6 x C)

What do you think?
Regards

@atm-maxime
Copy link
Member

I think either you need production modules to manufacture your set product and consume product 1,2 and 3. Or you need a specific virtual stock calculation on virtual products to show you how many you can sell based on the components in stock.

In reality you never have at the same time the stock of your components and the stock of your set. Your example here "To make Set1 I need 1 x Product1, 1 x Product2, 1 x Product3 so if I have 5 x Product1, 5 x Product2, 5 x Product3 then I should have 5 x Set1" is wrong in my opinion. In stock either you have your components or you have your set but you can't have both at the same time or this means your stock is doubled. Or the "5 x 1 set1" is a virtual stock as said before, or something we might call "the composable stock".

I think the good feature request you need is that your virtual product doesn't have a stock, only a possible stock, and that this calculated value should be displayed on the virtual product card and when you choose this product in a document.

@BebZ
Copy link

BebZ commented Mar 17, 2020

I like your approach and you explained very well

in your video virtual stock of virtual product should have increased of 2
and real stock not increase
because you increased component by 10 units, witch gives a virtual stock of 2 virtual products composed with 5 components in it
Am I right ?

I think we need more fields to differentiate virtual stock (stocks - orders + supplier orders)
and possible stock of virtual products if the product is a virtual one.

Understand ?

@futurehousestore
Copy link
Contributor Author

Thank you @BebZ In the video I have adjusted parent product by 10 so virtual should increase by 50 (and it was as expected) but then I adjusted quantity of the virtual product to 0 so the parent product should be 0 as well. The example from the video is
1 x Parent product (P00014) = 5 x virtual product (P00014_virtual)
Parent product should increase/decrease by 1 if the quantity of virtual product (P00014) meets the criteria (5 units) I have created a simple formula in excel that explains it better and attached recordings
How it should work when adjusting parent product (P00014) quantity
https://1drv.ms/v/s!AkCF1g4VB-lZhn1W7aN0kBt3lGay?e=DNDGWL
and below how it should work when adjusting virtual product (P00014_virtual) quantity
https://1drv.ms/v/s!AkCF1g4VB-lZhn5GO74PlNjASlva?e=GkJdRI

@futurehousestore
Copy link
Contributor Author

I think either you need production modules to manufacture your set product and consume product 1,2 and 3. Or you need a specific virtual stock calculation on virtual products to show you how many you can sell based on the components in stock.

In reality you never have at the same time the stock of your components and the stock of your set. Your example here "To make Set1 I need 1 x Product1, 1 x Product2, 1 x Product3 so if I have 5 x Product1, 5 x Product2, 5 x Product3 then I should have 5 x Set1" is wrong in my opinion. In stock either you have your components or you have your set but you can't have both at the same time or this means your stock is doubled. Or the "5 x 1 set1" is a virtual stock as said before, or something we might call "the composable stock".

I think the good feature request you need is that your virtual product doesn't have a stock, only a possible stock, and that this calculated value should be displayed on the virtual product card and when you choose this product in a document.

Thanks @atm-maxime but I think I can have "at the same time the stock of your components and the stock of your set"
One of the examples from my dolibarr is as per below
I buy cables on roll 100m and I sell them per roll or per meter and if I have 2 rolls it means I have 200 meters but if I have 160 meters it means I have only one roll available.
https://1drv.ms/v/s!AkCF1g4VB-lZhn8x0mrn8Kg7cxvc?e=e4bRVh

@futurehousestore
Copy link
Contributor Author

@atm-maxime any idea how I can archive this functionality? If the Dolibarr team believes the actual functionality is the right one I do respect that but to stop wasting time in my business I would need to have the expected behaviour: When parent product quantity is changed the child quantity changes and when child product quantity is changed the parent product quantity is changed.
Thank you for your time.

@atm-maxime
Copy link
Member

Hi.
I think you'll need a specific development for this.
"When parent product quantity is changed the child quantity changes" works already.
"When child product quantity is changed the parent product quantity is changed" you need a specific. What happens if your child product has several parent product ?

@futurehousestore
Copy link
Contributor Author

futurehousestore commented Apr 3, 2020

Thanks @atm-maxime When the child product has several parent products then the parent products should change only if the criteria are met. Let's say we have parent products "A", "B", "C" and "D" and all of them need a child product "Child1".
Criteria:
A needs 2 x Child1
B needs 5 x Child1
C needs 1 x Child1
D needs 10 x Child1
So if we have in stock 100 of Child1 we can make 50 x A, 20 x B, 100 x C and 10 x D
Example 1:
If the stock of Child1 is reduced by 4 units (96 left) then our parent products should change accordingly: A = 48, B = 19, C = 96, D = 9 (that's because we have enough of Child1 to create these amounts of the parent products).
As I have shown in the previous videos the parent product quantity should change only if the criteria are met.
Example 2:
If the stock of Child1 increase by 5 (105 units in stock) then we should have A = 52 (105/2=52,5), B = 21 (105/5=21), C = 105 (105/1=105), D = 10 (105/10=10.5)
The stock of the parent product should be always round down to show the correct stock level.

@atm-maxime
Copy link
Member

Example 3:
If stock of B changes, then stock of Child 1 changes accordingly (standard Dolibarr) and then we must change stock for A, C, D (not B) and without changing again Child 1 or we will land in an infinite loop...
I think this is doable in a specific external module based on stock movements triggers. I'd say 1 day of development neeeded.

@futurehousestore
Copy link
Contributor Author

yes in Example 3 when the stock of product B changes then the child should change and products A, C and D should change as well but only if the change meets criteria (A needs 2 x Child1, B needs 5 x Child1, C needs 1 x Child1, D needs 10 x Child1)

@eldy
Copy link
Member

eldy commented Apr 13, 2020

Current behavior is the expected behavior.
Goal of virtual product is to manage "kit/set" of product.
For manufacturing needs, the v12 may be the answer. For a specific rule, like the one defined by atm-maxime, an external module is a better choice than a change into Dolibarr core, so i close the ticket.

@eldy eldy closed this as completed Apr 13, 2020
@futurehousestore
Copy link
Contributor Author

Can someone recommend an external module which would allow achieving that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a bug (something does not work as expected)
Projects
None yet
Development

No branches or pull requests

4 participants