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

Fix: replenish.php: no virtual stock shown for warehouses that have no physical stock #29396

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

atm-florianm
Copy link
Contributor

Issue

Currently, the replenish page can be filtered by warehouse. If you use this filter in the "virtual stock" mode, it shows a column with the virtual stock of every product for the selected warehouse.

However, when the product doesn't currently have any physical stock in that warehouse, the virtual stock is not computed even though it might be non-zero (for instance if the warehouse is the default warehouse for this product and there are supplier orders for that product, or if you allow negative stock and there are future shipments with lines referring to this warehouse and this product).

This is because load_virtual_stock() loops over keys of $this->stock_warehouses (an array indexed by warehouse), whose keys are initialized when computing the physical stock. Therefore, warehouses with no physical stock don't have a key in this array and are not considered for virtual stock computation.

Proposed solution

This fix initializes the array $this->stock_warehouses with empty objects for every warehouse.

An alternative solution would be, in load_virtual_stock(), to loop over all warehouses instead of those listed as keys of $this->stock_warehouses. It would have a smaller memory footprint (no need to keep an array of mostly empty values for possibly thousands of warehouses) but this might be harder to read.

@eldy
Copy link
Member

eldy commented May 24, 2024

The solution hurt me becasse it change code int product.class.php
when it should fix by changing code into the incriminated page so product/stock/replenish.php

Can't you try to add a fix inside this page ?

@eldy eldy added the Discussion Some questions or discussions are opened and wait answers of author or other people to be processed label May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Some questions or discussions are opened and wait answers of author or other people to be processed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants