From f3a258766b72d04dc12e0ce8bee4c61e455ea527 Mon Sep 17 00:00:00 2001 From: snt Date: Thu, 12 Feb 2026 19:33:33 +0100 Subject: [PATCH] [FIX] product_sale_price_from_pricelist: use write() for price update Use write() instead of direct assignment to ensure last_purchase_price_received is persisted before computing theoretical price. The with_company() creates a new recordset and direct assignment may not propagate correctly. --- .../models/stock_move.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/product_sale_price_from_pricelist/models/stock_move.py b/product_sale_price_from_pricelist/models/stock_move.py index 26521be..9e5a408 100644 --- a/product_sale_price_from_pricelist/models/stock_move.py +++ b/product_sale_price_from_pricelist/models/stock_move.py @@ -75,10 +75,12 @@ class StockMove(models.Model): ), move.product_id.last_purchase_price_compute_type, ) - move.product_id.with_company( - move.company_id - ).last_purchase_price_received = price_updated - move.product_id.with_company( - move.company_id - )._compute_theoritical_price() + # Use write() to ensure value is persisted before computing price + product_company = move.product_id.with_company(move.company_id) + product_company.write( + { + "last_purchase_price_received": price_updated, + } + ) + product_company._compute_theoritical_price() return res