From f2a4d537c670a9c33dcf03d00baa19c1dca85c19 Mon Sep 17 00:00:00 2001 From: "David (dafr)" <dafr@odoo.com> 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#104895 Signed-off-by: William Henrotin (whe) <whe@odoo.com> --- addons/stock_account/models/stock_move.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock_account/models/stock_move.py b/addons/stock_account/models/stock_move.py index f0904cb587ad..de098d81a2d7 100644 --- a/addons/stock_account/models/stock_move.py +++ b/addons/stock_account/models/stock_move.py @@ -274,11 +274,11 @@ class StockMove(models.Model): continue for svl in stock_valuation_layers.with_context(active_test=False): - if not svl.product_id.valuation == 'real_time': + if not svl.with_context(force_company=svl.company_id.id).product_id.valuation == 'real_time': continue if svl.currency_id.is_zero(svl.value): continue - svl.stock_move_id._account_entry_move(svl.quantity, svl.description, svl.id, svl.value) + svl.stock_move_id.with_context(force_company=svl.company_id.id)._account_entry_move(svl.quantity, svl.description, svl.id, svl.value) stock_valuation_layers._check_company() -- GitLab