[MIG] product_category_tax from v14 to v16
This commit is contained in:
@@ -1,17 +1,17 @@
|
|||||||
# Copyright 2015-2020 Akretion (http://www.akretion.com)
|
# Copyright 2015-2025 Akretion France (https://www.akretion.com)
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Product Category Tax',
|
'name': 'Product Category Tax',
|
||||||
'version': '14.0.1.0.0',
|
'version': '16.0.1.0.0',
|
||||||
'category': 'Accounting & Finance',
|
'category': 'Accounting & Finance',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'summary': 'Adds sale and purchase taxes on product category',
|
'summary': 'Adds sale and purchase taxes on product category',
|
||||||
'description': "",
|
'description': "",
|
||||||
'author': 'Akretion',
|
'author': 'Akretion',
|
||||||
'website': 'http://www.akretion.com',
|
'website': 'https://github.com/akretion/odoo-usability',
|
||||||
'depends': ['account'],
|
'depends': ['account'],
|
||||||
'data': ['product_view.xml'],
|
'data': ['product_view.xml'],
|
||||||
'installable': False,
|
'installable': True,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# Copyright 2015-2020 Akretion (http://www.akretion.com)
|
# Copyright 2015-2025 Akretion France (https://www.akretion.com)
|
||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
from odoo import api, fields, models, _
|
from odoo import api, fields, models, Command, _
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
@@ -24,8 +24,8 @@ class ProductCategTaxMixin(models.AbstractModel):
|
|||||||
# of replacing the taxes... and I want to REPLACE the taxes
|
# of replacing the taxes... and I want to REPLACE the taxes
|
||||||
# So I have to use the awful syntax (6, 0, [IDs])
|
# So I have to use the awful syntax (6, 0, [IDs])
|
||||||
# values are sent to ('taxes_id' and 'supplier_taxes_id')
|
# values are sent to ('taxes_id' and 'supplier_taxes_id')
|
||||||
return ([(6, 0, categ.sale_tax_ids.ids)],
|
return ([Command.set(categ.sale_tax_ids.ids)],
|
||||||
[(6, 0, categ.purchase_tax_ids.ids)])
|
[Command.set(categ.purchase_tax_ids.ids)])
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def write_or_create(self, vals):
|
def write_or_create(self, vals):
|
||||||
@@ -34,10 +34,11 @@ class ProductCategTaxMixin(models.AbstractModel):
|
|||||||
vals['taxes_id'], vals['supplier_taxes_id'] =\
|
vals['taxes_id'], vals['supplier_taxes_id'] =\
|
||||||
self.apply_tax_from_category(categ)
|
self.apply_tax_from_category(categ)
|
||||||
|
|
||||||
@api.model
|
@api.model_create_multi
|
||||||
def create(self, vals):
|
def create(self, vals_list):
|
||||||
|
for vals in vals_list:
|
||||||
self.write_or_create(vals)
|
self.write_or_create(vals)
|
||||||
return super().create(vals)
|
return super().create(vals_list)
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
self.write_or_create(vals)
|
self.write_or_create(vals)
|
||||||
@@ -48,12 +49,10 @@ class ProductTemplate(models.Model):
|
|||||||
_inherit = ['product.template', 'product.categ.tax.mixin']
|
_inherit = ['product.template', 'product.categ.tax.mixin']
|
||||||
_name = 'product.template'
|
_name = 'product.template'
|
||||||
|
|
||||||
@api.constrains('taxes_id', 'supplier_taxes_id')
|
@api.constrains('taxes_id', 'supplier_taxes_id', 'categ_id')
|
||||||
def _check_tax_categ(self):
|
def _check_tax_categ(self):
|
||||||
# self.name != 'Pay Debt' is a stupid hack to avoid blocking the
|
|
||||||
# installation of the module 'pos_debt_notebook'
|
|
||||||
for pt in self:
|
for pt in self:
|
||||||
if pt.categ_id: # and self.name != 'Pay Debt':
|
if pt.categ_id:
|
||||||
if pt.categ_id.sale_tax_ids.ids != pt.taxes_id.ids:
|
if pt.categ_id.sale_tax_ids.ids != pt.taxes_id.ids:
|
||||||
raise ValidationError(_(
|
raise ValidationError(_(
|
||||||
"The sale taxes configured on the product '%s' "
|
"The sale taxes configured on the product '%s' "
|
||||||
|
|||||||
Reference in New Issue
Block a user