[FIX] stock: clean quants after moving package
When moving a package, the quant at source location is not automatically removed To reproduce the issue: 1. In Settings, enable - Packages - Storage Locations 2. Create a storable product P 3. Update the on hand quantity - 1 x P at WH/Stock in package PK 4. Create a planned delivery D with 1 x P 5. Confirm and reserve D - PK should be reserved 6. Validate 7. Open the package - Its location is "Partner Locations/Customers", which make sense 8. Inventory > Configuration > ... > Locations, open WH/Stock 9. Current Stock Error: There is a line with PK. The quantity is 0 but still, it create some confusion for the user who could believe that the package is still in WH/Stock This issue does not occur if the user goes through the product form and click on the on hand quantity. The "incorrect" quant will not be there. This is because, when loading the action, we call `_quant_tasks`: https://github.com/odoo/odoo/blob/05a7f5c04804423cfc3a833a1b3f0b5eec3fc147/addons/stock/models/stock_quant.py#L296-L300 This method will clean the quants (merge & unlink) However, in the above case (step 9), the action is defined on XML side: https://github.com/odoo/odoo/blob/7d4dfeb0e26b387dee312897264a68963f90267f/addons/stock/views/stock_location_views.xml#L24-L26 https://github.com/odoo/odoo/blob/d956e719d43c68abe6210e3136db576aaa6f60b8/addons/stock/views/stock_quant_views.xml#L190-L196 So, we can't make it behave as it does from the product form, unfortunatly. As alternative, we can try to call `_unlink_zero_quants` when we are moving a package (and not `_quant_tasks` for perf matters as, so far, we will not have any quant to merge) OPW-3292238 closes odoo/odoo#122768 X-original-commit: 5fb84ba5 Signed-off-by:William Henrotin (whe) <whe@odoo.com>
Loading
Please register or sign in to comment