From 33a92dcc4becd1e13b64d029b1b2549a747bee5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Wed, 9 Aug 2017 13:49:53 +0200 Subject: [PATCH] [REF] getting hs code should be done on the product.product, indeed in some really special case hscode can depend of the variant. Moving the method to the product.product make it inheritable --- intrastat_product/models/account_invoice.py | 2 +- product_harmonized_system/models/product_template.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/intrastat_product/models/account_invoice.py b/intrastat_product/models/account_invoice.py index b62d4db..080d1df 100644 --- a/intrastat_product/models/account_invoice.py +++ b/intrastat_product/models/account_invoice.py @@ -121,7 +121,7 @@ class AccountInvoiceLine(models.Model): if product: product = self.env['product.product'].browse(product) - hs_code = product.product_tmpl_id.get_hs_code_recursively() + hs_code = product.get_hs_code_recursively() if hs_code: res['value']['hs_code_id'] = hs_code.id else: diff --git a/product_harmonized_system/models/product_template.py b/product_harmonized_system/models/product_template.py index 6dfaa0e..34bd5ee 100644 --- a/product_harmonized_system/models/product_template.py +++ b/product_harmonized_system/models/product_template.py @@ -39,6 +39,10 @@ class ProductTemplate(models.Model): help="Country of origin of the product i.e. product " "'made in ____'.") + +class ProductProduct(models.Model): + _inherit = 'product.product' + @api.multi def get_hs_code_recursively(self): self.ensure_one()