From 66ea264fc2d57de85e92cac4aa5e6ee9cd80e952 Mon Sep 17 00:00:00 2001
From: niyasraphy <niyasraphyk@gmail.com>
Date: Mon, 3 Apr 2023 11:14:46 +0000
Subject: [PATCH] [FIX] stock_landed_costs: missing required account on invoice
 line

before this commit, on creating a vendor bill with
landed cost product, is not allowing to save the bill,
it shows the exception that missing required account
on accountable invoice line.

steps to reproduce:

* create a product category with inventory
valuation set as Manual
* create a landed cost product using above category
* enable anglo saxon accounting in accounting settings
* create a vendor bill with this product and click save
* exception is shown: missing required account
on accountable invoice line

after this commit, the exception wont be shown

closes odoo/odoo#117474

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
---
 addons/stock_landed_costs/models/account_move.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/addons/stock_landed_costs/models/account_move.py b/addons/stock_landed_costs/models/account_move.py
index b70a6d11ab3a..4959eb4ba708 100644
--- a/addons/stock_landed_costs/models/account_move.py
+++ b/addons/stock_landed_costs/models/account_move.py
@@ -78,6 +78,6 @@ class AccountMoveLine(models.Model):
 
     def create(self, vals_list):
         lines = super().create(vals_list)
-        for line in lines.filtered('is_landed_costs_line'):
+        for line in lines.filtered(lambda x: x.is_landed_costs_line and x.product_id.categ_id.property_valuation == 'real_time'):
             line.account_id = line._get_landed_costs_account(line.product_id.product_tmpl_id._get_product_accounts())
         return lines
-- 
GitLab