-
- Downloads
[FIX] {sale,purchase}_stock: propagate package type to stock moves
Current behaviour:
If you have a confirmed SO, with a `sale.order.line` that has a
`product_packaging_id`, and you write a new `product_packaging_id`,
the "Delivery Order" has 2 lines, 1 move with the old qty and the old
packaging, and another line with the difference of qty and the new packaging.
Same behaviour is present on purchase side.
Expected behaviour:
If you have multiple `stock.move.line` from the same `sale.order.line`,
they should be able to merge, when you changed the `product_packaging_id`.
Ex: If you edit an SOL from 1 pack of 10 to 1 pack of 20, we should have
1 move line with qty 20 in packs of 20, instead of 2 lines, one with qty 10
in packs of 10, and another line with qty 10 in packs of 20.
Same behaviour is expected on purchase side.
Steps to reproduce:
- Install Sales and Inventory
- Activate "Product Packaging" in Settings
- Create a new product with 2 types of packaging
- PackOf10 with quantity of 10
- PackOf20 with quantity of 20
- Create a SO with a new line that product, quantity 10
- Confirm the SO
- Edit the SOL with 1 pack of 20 (`product_uom_qty`=20)
- The "Delivery Order" has 2 lines, instead of 1 with the new packaging
Reason for the problem:
When saving the SO/PO, a new `procurement` is created which will create
a new `stock.move.line` with the new packaging. This will prevent the
lines to merge correctly, because they have different packaging.
Fix:
When writing the `product_packaging_id` on a `sale.order.line`/`purchase.order.line`,
we directly write the package on the `stock.move.line`,
before any `procurements` are created, so the generate move lines
can correctly be merged.
Affected versions:
- 15.0
- saas-15.2
- saas-15.3
- 16.0
- master
opw-3002612
closes odoo/odoo#107223
Signed-off-by:
William Henrotin (whe) <whe@odoo.com>
Showing
- addons/purchase_stock/models/purchase.py 6 additions, 0 deletionsaddons/purchase_stock/models/purchase.py
- addons/purchase_stock/tests/test_purchase_order.py 54 additions, 0 deletionsaddons/purchase_stock/tests/test_purchase_order.py
- addons/sale_stock/models/sale_order.py 5 additions, 0 deletionsaddons/sale_stock/models/sale_order.py
- addons/sale_stock/tests/test_sale_stock.py 33 additions, 5 deletionsaddons/sale_stock/tests/test_sale_stock.py
- addons/stock/models/stock_move.py 26 additions, 0 deletionsaddons/stock/models/stock_move.py
Loading