From 23d7c12c5a5e2e1733e6c2705110deb14ff4cf2c Mon Sep 17 00:00:00 2001 From: InCeyN Date: Thu, 20 Apr 2023 14:03:06 +0000 Subject: [PATCH] [FIX] stock_account: location default account_id Behaviour before commit: If the location is a production or inventory location, you can set an account_id for the valuation. Once this account_id is set, it will still be there if you change the type of location to a view location for example. This may not be the right account_id given the new type of location. Behaviour after commit: Check if the location is of a specific type, if it's not inventory or production, it will take the default valuation account id from the product category. Otherwise it will take the one set on the location. OPW-3269584 closes odoo/odoo#119344 X-original-commit: 3f0ea5d0fa5a96eb78e4637781698121434ee069 Signed-off-by: William Henrotin (whe) --- addons/stock_account/models/stock_move.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/stock_account/models/stock_move.py b/addons/stock_account/models/stock_move.py index e6fb20946ec..4c905a48d44 100644 --- a/addons/stock_account/models/stock_move.py +++ b/addons/stock_account/models/stock_move.py @@ -379,7 +379,10 @@ class StockMove(models.Model): return self.location_id.valuation_out_account_id.id or accounts_data['stock_input'].id def _get_dest_account(self, accounts_data): - return self.location_dest_id.valuation_in_account_id.id or accounts_data['stock_output'].id + if not self.location_dest_id.usage in ('production', 'inventory'): + return accounts_data['stock_output'].id + else: + return self.location_dest_id.valuation_in_account_id.id or accounts_data['stock_output'].id def _prepare_account_move_line(self, qty, cost, credit_account_id, debit_account_id, svl_id, description): """