From b40bd15c9ce43b60a8993afbe61c56a3bb9f782f Mon Sep 17 00:00:00 2001 From: Walid Date: Wed, 21 Feb 2024 12:46:21 +0100 Subject: [PATCH] [FIX] purchase_stock: merge allocated moves Steps to reproduce: - In User settings add 'allocation reports' group to the admin User - In Inventory settings enable allocation reports - Create a stored product with 0/0 reordering rules and set a vendor - Create an SO for that product - Confirm the generated PO and click assign all on its receipt's allocation report - Reduce the quantity on the SO and save Bug: a return is created instead of adjusting the quantity to deliver the stock moves were not merged because their procurement method do not match ('make_to_stock' / 'make_to_order') Fix: ignore procurement method when merging the moves (introducing new config parameter) opw-3621316 closes odoo/odoo#154942 X-original-commit: 337d4c79bf51f0d1705a80341fa83a88c5297128 Signed-off-by: William Henrotin (whe) Signed-off-by: Walid Hanniche (waha) --- addons/purchase_stock/models/stock_move.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/purchase_stock/models/stock_move.py b/addons/purchase_stock/models/stock_move.py index ac406ed23ed..4036598a494 100644 --- a/addons/purchase_stock/models/stock_move.py +++ b/addons/purchase_stock/models/stock_move.py @@ -25,7 +25,10 @@ class StockMove(models.Model): @api.model def _prepare_merge_negative_moves_excluded_distinct_fields(self): - return super()._prepare_merge_negative_moves_excluded_distinct_fields() + ['created_purchase_line_ids'] + excluded_fields = super()._prepare_merge_negative_moves_excluded_distinct_fields() + ['created_purchase_line_id'] + if self.env['ir.config_parameter'].sudo().get_param('purchase_stock.merge_different_procurement'): + excluded_fields += ['procure_method'] + return excluded_fields def _compute_partner_id(self): # dropshipped moves should have their partner_ids directly set