From 1648ee1abff1ae12b3933baa85a2e048fa2eb557 Mon Sep 17 00:00:00 2001 From: Walid Date: Fri, 12 Apr 2024 16:17:08 +0200 Subject: [PATCH] [FIX] stock_landed_costs: skip display lines in reconciliation Steps to reproduce: - Create a vendor bill with landed costs - Add section and note lines - Try posting the bill (ERROR) Bug: display lines should be skipped opw-3715660 closes odoo/odoo#161791 X-original-commit: 3174c4a793f24782d835a15d96376e45b5f333e4 Signed-off-by: Walid Hanniche (waha) Signed-off-by: William Henrotin (whe) --- addons/stock_landed_costs/models/stock_landed_cost.py | 3 ++- addons/stock_landed_costs/tests/test_stock_landed_costs.py | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/stock_landed_costs/models/stock_landed_cost.py b/addons/stock_landed_costs/models/stock_landed_cost.py index a2e41708994..9abd9ddd807 100644 --- a/addons/stock_landed_costs/models/stock_landed_cost.py +++ b/addons/stock_landed_costs/models/stock_landed_cost.py @@ -188,7 +188,8 @@ class StockLandedCost(models.Model): for product in cost.cost_lines.product_id: accounts = product.product_tmpl_id.get_product_accounts() input_account = accounts['stock_input'] - all_amls.filtered(lambda aml: aml.account_id == input_account and not aml.reconciled).reconcile() + all_amls.filtered(lambda aml: aml.account_id == input_account and not aml.reconciled\ + and not aml.display_type in ('line_section', 'line_note')).reconcile() def get_valuation_lines(self): self.ensure_one() diff --git a/addons/stock_landed_costs/tests/test_stock_landed_costs.py b/addons/stock_landed_costs/tests/test_stock_landed_costs.py index 689e09ca135..31f06df1894 100644 --- a/addons/stock_landed_costs/tests/test_stock_landed_costs.py +++ b/addons/stock_landed_costs/tests/test_stock_landed_costs.py @@ -205,6 +205,13 @@ class TestStockLandedCosts(TestStockLandedCostsCommon): po.action_create_invoice() bill = po.invoice_ids bill.invoice_date = fields.Date.today() + + self.env['account.move.line'].create({ + 'move_id': bill.id, + 'display_type': 'line_section', + 'name': 'Great Section', + }) + bill._post() landed_cost_aml = bill.invoice_line_ids.filtered(lambda l: l.product_id == self.landed_cost)