From 2e95fda97d29cab4819b4b64edfb956cb52f3a6f Mon Sep 17 00:00:00 2001 From: Adrien Widart Date: Thu, 18 Mar 2021 10:49:31 +0000 Subject: [PATCH] [IMP] stock_account: add hook for eligible for COGS Let people be able to customize how to filter the condition closes odoo/odoo#70418 Signed-off-by: Steve Van Essche --- addons/stock_account/models/account_move.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/stock_account/models/account_move.py b/addons/stock_account/models/account_move.py index d90c71f0048..adbe108f3e6 100644 --- a/addons/stock_account/models/account_move.py +++ b/addons/stock_account/models/account_move.py @@ -112,7 +112,7 @@ class AccountMove(models.Model): for line in move.invoice_line_ids: # Filter out lines being not eligible for COGS. - if line.product_id.type != 'product' or line.product_id.valuation != 'real_time': + if not line._eligible_for_cogs(): continue # Retrieve accounts needed to generate the COGS. @@ -232,6 +232,10 @@ class AccountMoveLine(models.Model): return accounts['stock_input'] return super(AccountMoveLine, self)._get_computed_account() + def _eligible_for_cogs(self): + self.ensure_one() + return self.product_id.type == 'product' and self.product_id.valuation == 'real_time' + def _stock_account_get_anglo_saxon_price_unit(self): self.ensure_one() if not self.product_id: