From db1ce8b591eb7785dfb55ed931e9d72f88ddec67 Mon Sep 17 00:00:00 2001 From: len-odoo Date: Wed, 14 Nov 2018 10:37:47 +0000 Subject: [PATCH] [FIX] stock_account: add a force_company to update the correct price in FIFO costing Fine-tuning of commit: o50f77ba091189bd785d459c042a6cec04a125fdb When costing is in FIFO mode, product price can be updated whereas the current user doesn't have the right to modify the products. It therefore introduced a sudo() to make this computation; however since this is modifying a company-dependent field, a force_company was missing to update the correct one. Closes #28487 opw 1907377 closes odoo/odoo#28662 --- addons/stock_account/models/stock.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock_account/models/stock.py b/addons/stock_account/models/stock.py index 1e6a76afc8f..37969828357 100644 --- a/addons/stock_account/models/stock.py +++ b/addons/stock_account/models/stock.py @@ -268,7 +268,8 @@ class StockMove(models.Model): # Update the standard price with the price of the last used candidate, if any. if new_standard_price and move.product_id.cost_method == 'fifo': - move.product_id.sudo().standard_price = new_standard_price + move.product_id.sudo().with_context(force_company=move.company_id.id) \ + .standard_price = new_standard_price # If there's still quantity to value but we're out of candidates, we fall in the # negative stock use case. We chose to value the out move at the price of the