diff --git a/product_category_tax/README.rst b/product_category_tax/README.rst index b18bbe7..652bbff 100644 --- a/product_category_tax/README.rst +++ b/product_category_tax/README.rst @@ -11,7 +11,7 @@ This module will allow you to configure sale and purchase taxes on product categ Configuration ============= -Set the taxes on the product categories via the menu *Sales > Configuration > Products > Product Categories*. +Set the taxes on the product categories via the menu *Inventory > Configuration > Products > Product Categories*. Credits ======= diff --git a/product_category_tax/__init__.py b/product_category_tax/__init__.py index d7d7308..9649db7 100644 --- a/product_category_tax/__init__.py +++ b/product_category_tax/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import product diff --git a/product_category_tax/__manifest__.py b/product_category_tax/__manifest__.py index 92828e0..10a9c5d 100644 --- a/product_category_tax/__manifest__.py +++ b/product_category_tax/__manifest__.py @@ -1,11 +1,10 @@ -# -*- coding: utf-8 -*- -# © 2015-2016 Akretion (http://www.akretion.com) +# Copyright 2015-2020 Akretion (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Product Category Tax', - 'version': '10.0.1.0.0', + 'version': '14.0.1.0.0', 'category': 'Accounting & Finance', 'license': 'AGPL-3', 'summary': 'Adds sale and purchase taxes on product category', diff --git a/product_category_tax/product.py b/product_category_tax/product.py index 64bb198..560de2f 100644 --- a/product_category_tax/product.py +++ b/product_category_tax/product.py @@ -1,14 +1,14 @@ -# -*- coding: utf-8 -*- -# © 2015-2016 Akretion (http://www.akretion.com) +# Copyright 2015-2020 Akretion (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields, api, _ +from odoo import api, fields, models, _ from odoo.exceptions import ValidationError class ProductCategTaxMixin(models.AbstractModel): _name = 'product.categ.tax.mixin' + _description = 'Common code for taxes on product categories' @api.onchange('categ_id') def onchange_categ_id(self): @@ -37,38 +37,37 @@ class ProductCategTaxMixin(models.AbstractModel): @api.model def create(self, vals): self.write_or_create(vals) - return super(ProductCategTaxMixin, self).create(vals) + return super().create(vals) - @api.multi def write(self, vals): self.write_or_create(vals) - return super(ProductCategTaxMixin, self).write(vals) + return super().write(vals) class ProductTemplate(models.Model): _inherit = ['product.template', 'product.categ.tax.mixin'] _name = 'product.template' - @api.one @api.constrains('taxes_id', 'supplier_taxes_id') def _check_tax_categ(self): # self.name != 'Pay Debt' is a stupid hack to avoid blocking the # installation of the module 'pos_debt_notebook' - if self.categ_id: # and self.name != 'Pay Debt': - if self.categ_id.sale_tax_ids.ids != self.taxes_id.ids: - raise ValidationError(_( - "The sale taxes configured on the product '%s' " - "are not the same as the sale taxes configured " - "on it's related internal category '%s'.") - % (self.name, self.categ_id.name_get()[0][1])) - if ( - self.categ_id.purchase_tax_ids.ids != - self.supplier_taxes_id.ids): - raise ValidationError(_( - "The purchase taxes configured on the product '%s' " - "are not the same as the purchase taxes configured " - "on it's related internal category '%s'.") - % (self.name, self.categ_id.name_get()[0][1])) + for pt in self: + if pt.categ_id: # and self.name != 'Pay Debt': + if pt.categ_id.sale_tax_ids.ids != pt.taxes_id.ids: + raise ValidationError(_( + "The sale taxes configured on the product '%s' " + "are not the same as the sale taxes configured " + "on it's related internal category '%s'.") + % (pt.display_name, pt.categ_id.display_name)) + if ( + pt.categ_id.purchase_tax_ids.ids != + pt.supplier_taxes_id.ids): + raise ValidationError(_( + "The purchase taxes configured on the product '%s' " + "are not the same as the purchase taxes configured " + "on it's related internal category '%s'.") + % (pt.display_name, pt.categ_id.display_name)) class ProductProduct(models.Model): diff --git a/product_category_tax/product_view.xml b/product_category_tax/product_view.xml index 20f90ef..ad733cb 100644 --- a/product_category_tax/product_view.xml +++ b/product_category_tax/product_view.xml @@ -1,6 +1,6 @@ @@ -13,10 +13,10 @@ - + - +