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) + +