[MIG] product_category_tax from v10 to v14
This commit is contained in:
@@ -11,7 +11,7 @@ This module will allow you to configure sale and purchase taxes on product categ
|
|||||||
Configuration
|
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
|
Credits
|
||||||
=======
|
=======
|
||||||
|
|||||||
@@ -1,3 +1 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from . import product
|
from . import product
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2015-2020 Akretion (http://www.akretion.com)
|
||||||
# © 2015-2016 Akretion (http://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': '10.0.1.0.0',
|
'version': '14.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',
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# Copyright 2015-2020 Akretion (http://www.akretion.com)
|
||||||
# © 2015-2016 Akretion (http://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 models, fields, api, _
|
from odoo import api, fields, models, _
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
class ProductCategTaxMixin(models.AbstractModel):
|
class ProductCategTaxMixin(models.AbstractModel):
|
||||||
_name = 'product.categ.tax.mixin'
|
_name = 'product.categ.tax.mixin'
|
||||||
|
_description = 'Common code for taxes on product categories'
|
||||||
|
|
||||||
@api.onchange('categ_id')
|
@api.onchange('categ_id')
|
||||||
def onchange_categ_id(self):
|
def onchange_categ_id(self):
|
||||||
@@ -37,38 +37,37 @@ class ProductCategTaxMixin(models.AbstractModel):
|
|||||||
@api.model
|
@api.model
|
||||||
def create(self, vals):
|
def create(self, vals):
|
||||||
self.write_or_create(vals)
|
self.write_or_create(vals)
|
||||||
return super(ProductCategTaxMixin, self).create(vals)
|
return super().create(vals)
|
||||||
|
|
||||||
@api.multi
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
self.write_or_create(vals)
|
self.write_or_create(vals)
|
||||||
return super(ProductCategTaxMixin, self).write(vals)
|
return super().write(vals)
|
||||||
|
|
||||||
|
|
||||||
class ProductTemplate(models.Model):
|
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.one
|
|
||||||
@api.constrains('taxes_id', 'supplier_taxes_id')
|
@api.constrains('taxes_id', 'supplier_taxes_id')
|
||||||
def _check_tax_categ(self):
|
def _check_tax_categ(self):
|
||||||
# self.name != 'Pay Debt' is a stupid hack to avoid blocking the
|
# self.name != 'Pay Debt' is a stupid hack to avoid blocking the
|
||||||
# installation of the module 'pos_debt_notebook'
|
# installation of the module 'pos_debt_notebook'
|
||||||
if self.categ_id: # and self.name != 'Pay Debt':
|
for pt in self:
|
||||||
if self.categ_id.sale_tax_ids.ids != self.taxes_id.ids:
|
if pt.categ_id: # and self.name != 'Pay Debt':
|
||||||
raise ValidationError(_(
|
if pt.categ_id.sale_tax_ids.ids != pt.taxes_id.ids:
|
||||||
"The sale taxes configured on the product '%s' "
|
raise ValidationError(_(
|
||||||
"are not the same as the sale taxes configured "
|
"The sale taxes configured on the product '%s' "
|
||||||
"on it's related internal category '%s'.")
|
"are not the same as the sale taxes configured "
|
||||||
% (self.name, self.categ_id.name_get()[0][1]))
|
"on it's related internal category '%s'.")
|
||||||
if (
|
% (pt.display_name, pt.categ_id.display_name))
|
||||||
self.categ_id.purchase_tax_ids.ids !=
|
if (
|
||||||
self.supplier_taxes_id.ids):
|
pt.categ_id.purchase_tax_ids.ids !=
|
||||||
raise ValidationError(_(
|
pt.supplier_taxes_id.ids):
|
||||||
"The purchase taxes configured on the product '%s' "
|
raise ValidationError(_(
|
||||||
"are not the same as the purchase taxes configured "
|
"The purchase taxes configured on the product '%s' "
|
||||||
"on it's related internal category '%s'.")
|
"are not the same as the purchase taxes configured "
|
||||||
% (self.name, self.categ_id.name_get()[0][1]))
|
"on it's related internal category '%s'.")
|
||||||
|
% (pt.display_name, pt.categ_id.display_name))
|
||||||
|
|
||||||
|
|
||||||
class ProductProduct(models.Model):
|
class ProductProduct(models.Model):
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
© 2015-2016 Akretion (http://www.akretion.com/)
|
Copyright 2015-2020 Akretion (http://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).
|
||||||
-->
|
-->
|
||||||
@@ -13,10 +13,10 @@
|
|||||||
<field name="inherit_id" ref="account.view_category_property_form" />
|
<field name="inherit_id" ref="account.view_category_property_form" />
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<field name="property_account_income_categ_id" position="after">
|
<field name="property_account_income_categ_id" position="after">
|
||||||
<field name="sale_tax_ids" widget="many2many_tags"/>
|
<field name="sale_tax_ids" widget="many2many_tags" options="{'no_create': True}"/>
|
||||||
</field>
|
</field>
|
||||||
<field name="property_account_expense_categ_id" position="after">
|
<field name="property_account_expense_categ_id" position="after">
|
||||||
<field name="purchase_tax_ids" widget="many2many_tags"/>
|
<field name="purchase_tax_ids" widget="many2many_tags" options="{'no_create': True}"/>
|
||||||
</field>
|
</field>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user