From b439ee1022fe5c99a7eea44b90812509fd782145 Mon Sep 17 00:00:00 2001 From: "Andrea Grazioso (agr-odoo)" Date: Wed, 30 Sep 2020 12:53:51 +0000 Subject: [PATCH] [FIX] stock_landed_costs: fix account for non-anglosaxon accounting companies Steps to reproduce: 1. Activate landed costs 2. Create a product that in the purchase tab has active 'Is a landed cost' 3. Add this product to a purchase order 4. Confirm the PO, create the bill and create landed costs entry Since they don't use anglosaxon accounting they expect the invoice line account to be used for the landed cost. It will come in empty as it is looking at the stock input account. opw-2332763 closes odoo/odoo#59626 X-original-commit: f500bec7c1a2de799c0d4deb9b7ee43a69b3b46a Signed-off-by: Nicolas Martinelli (nim) Signed-off-by: agr-odoo --- addons/stock_landed_costs/models/account_move.py | 2 +- addons/stock_landed_costs/tests/test_stockvaluationlayer.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/stock_landed_costs/models/account_move.py b/addons/stock_landed_costs/models/account_move.py index 72c1b6b05e2..80c7a5eacf1 100644 --- a/addons/stock_landed_costs/models/account_move.py +++ b/addons/stock_landed_costs/models/account_move.py @@ -30,7 +30,7 @@ class AccountMove(models.Model): 'cost_lines': [(0, 0, { 'product_id': l.product_id.id, 'name': l.product_id.name, - 'account_id': l.product_id.product_tmpl_id.get_product_accounts()['stock_input'].id, + 'account_id': l.product_id.product_tmpl_id.get_product_accounts()['stock_input'].id if self.company_id.anglo_saxon_accounting else l.account_id.id, 'price_unit': l.currency_id._convert(l.price_subtotal, l.company_currency_id, l.company_id, l.move_id.date), 'split_method': 'equal', }) for l in landed_costs_lines], diff --git a/addons/stock_landed_costs/tests/test_stockvaluationlayer.py b/addons/stock_landed_costs/tests/test_stockvaluationlayer.py index c2cb5354282..818aafd2b9f 100644 --- a/addons/stock_landed_costs/tests/test_stockvaluationlayer.py +++ b/addons/stock_landed_costs/tests/test_stockvaluationlayer.py @@ -520,9 +520,9 @@ class TestStockValuationLCFIFOVB(TestStockValuationLCCommon): self.assertEqual(lc.cost_lines.price_unit, 50) self.assertEqual(lc.cost_lines.product_id, self.productlc1) - input_aml = self._get_stock_input_move_lines()[-1] - self.assertEqual(input_aml.debit, 0) - self.assertEqual(input_aml.credit, 50) + expense_aml = self._get_expense_move_lines()[-1] + self.assertEqual(expense_aml.debit, 0) + self.assertEqual(expense_aml.credit, 50) valuation_aml = self._get_stock_valuation_move_lines()[-1] self.assertEqual(valuation_aml.debit, 50) self.assertEqual(valuation_aml.credit, 0)