[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.
This commit is contained in:
parent
b916779a67
commit
f3a258766b
1 changed files with 8 additions and 6 deletions
|
|
@ -75,10 +75,12 @@ class StockMove(models.Model):
|
||||||
),
|
),
|
||||||
move.product_id.last_purchase_price_compute_type,
|
move.product_id.last_purchase_price_compute_type,
|
||||||
)
|
)
|
||||||
move.product_id.with_company(
|
# Use write() to ensure value is persisted before computing price
|
||||||
move.company_id
|
product_company = move.product_id.with_company(move.company_id)
|
||||||
).last_purchase_price_received = price_updated
|
product_company.write(
|
||||||
move.product_id.with_company(
|
{
|
||||||
move.company_id
|
"last_purchase_price_received": price_updated,
|
||||||
)._compute_theoritical_price()
|
}
|
||||||
|
)
|
||||||
|
product_company._compute_theoritical_price()
|
||||||
return res
|
return res
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue