From 932fe0fd45ea7944569eb7160e2f5a8f133da325 Mon Sep 17 00:00:00 2001 From: santiky Date: Thu, 12 Aug 2021 16:39:19 +0200 Subject: [PATCH] =?UTF-8?q?vusca=20los=20impuestos=20en=20las=20cats=20pad?= =?UTF-8?q?re=20si=20la=20opci=C3=B3n=20general=20est=C3=A1=20habilitada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- product_category_tax/models/product_product.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/product_category_tax/models/product_product.py b/product_category_tax/models/product_product.py index db9d165..7f44f0a 100644 --- a/product_category_tax/models/product_product.py +++ b/product_category_tax/models/product_product.py @@ -22,8 +22,14 @@ class ProductProduct(models.Model): vals['supplier_taxes_id'] = category.buy_tax_id elif template_id: template = self.env["product.template"].browse(template_id) - category = template.categ_id - template.taxes_id = category.sell_tax_id - template.supplier_taxes_id = category.buy_tax_id + cat = template.categ_id + if not cat and self.env.user.company_id.use_parent_categories_to_determine_taxes: + while not cat.pos_categ_id and cat.parent_id: + cat = cat.parent_id + if cat: + template.taxes_id = cat.sell_tax_id + template.supplier_taxes_id = cat.buy_tax_id return super(ProductProduct, self).create(vals) + +