From 1cce589a654f0369abdd1962880f87ebb8ef0bd7 Mon Sep 17 00:00:00 2001 From: clementmbr Date: Thu, 4 Aug 2022 10:02:38 +0000 Subject: [PATCH] [FIX] purchase_stock: avoid updating kit components price_unit closes odoo/odoo#97656 X-original-commit: d491d2054ecb8852b0921a7b863f108a0b62155e Signed-off-by: William Henrotin (whe) --- addons/purchase_stock/models/purchase.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/purchase_stock/models/purchase.py b/addons/purchase_stock/models/purchase.py index 1a3f2a8b760..4f75a40560f 100644 --- a/addons/purchase_stock/models/purchase.py +++ b/addons/purchase_stock/models/purchase.py @@ -368,7 +368,10 @@ class PurchaseOrderLine(models.Model): previous_product_qty = {line.id: line.product_uom_qty for line in lines} result = super(PurchaseOrderLine, self).write(values) if 'price_unit' in values: - self.move_ids.price_unit = self.price_unit + for line in lines: + # Avoid updating kit components' stock.move + moves = line.move_ids.filtered(lambda s: s.state not in ('cancel', 'done') and s.product_id == line.product_id) + moves.write({'price_unit': line.price_unit}) if 'product_qty' in values: lines.with_context(previous_product_qty=previous_product_qty)._create_or_update_picking() return result