From a64a3dc90bd03ea8eb00e64347fe6624252b5edd Mon Sep 17 00:00:00 2001 From: "David (dafr)" Date: Thu, 3 Nov 2022 15:25:28 +0000 Subject: [PATCH] [FIX] stock_account: Use correct company for SVL account_move creation The valuation field of the product_id is company-dependent. If the user validate the picking in multi-company context with his current company != picking company, then the checks may fail, and the account move can not be created. closes odoo/odoo#105476 X-original-commit: c29c668d694ef8d675116d42393e496636072d13 Signed-off-by: William Henrotin (whe) Signed-off-by: David --- addons/stock_account/models/stock_valuation_layer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock_account/models/stock_valuation_layer.py b/addons/stock_account/models/stock_valuation_layer.py index c6fddb9da1b..0293736ba6e 100644 --- a/addons/stock_account/models/stock_valuation_layer.py +++ b/addons/stock_account/models/stock_valuation_layer.py @@ -42,14 +42,14 @@ class StockValuationLayer(models.Model): def _validate_accounting_entries(self): am_vals = [] for svl in self: - if not svl.product_id.valuation == 'real_time': + if not svl.with_company(svl.company_id).product_id.valuation == 'real_time': continue if svl.currency_id.is_zero(svl.value): continue move = svl.stock_move_id if not move: move = svl.stock_valuation_layer_id.stock_move_id - am_vals += move._account_entry_move(svl.quantity, svl.description, svl.id, svl.value) + am_vals += move.with_company(svl.company_id)._account_entry_move(svl.quantity, svl.description, svl.id, svl.value) if am_vals: account_moves = self.env['account.move'].sudo().create(am_vals) account_moves._post()