product_category_tax, configura impuestos por cada categoría de producto.
This commit is contained in:
parent
afe8319936
commit
f6023acc5a
9 changed files with 143 additions and 0 deletions
4
product_category_tax/models/__init__.py
Normal file
4
product_category_tax/models/__init__.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
from . import res_company
|
||||
from . import res_config_settings
|
||||
from . import product_product
|
||||
from . import product_category
|
19
product_category_tax/models/product_category.py
Normal file
19
product_category_tax/models/product_category.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
|
||||
# (http://www.eficent.com)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ProductCategory(models.Model):
|
||||
_inherit = 'product.category'
|
||||
|
||||
sell_tax_id = fields.Many2one(
|
||||
comodel_name="account.tax", string="Impuesto de venta del producto",
|
||||
help="Configura los productos de ésta categoría al impuesto definido aquí.",
|
||||
)
|
||||
|
||||
buy_tax_id = fields.Many2one(
|
||||
comodel_name="account.tax", string="Impuesto de compra del producto",
|
||||
help="Configura los productos de ésta categoría al impuesto definido aquí.",
|
||||
)
|
29
product_category_tax/models/product_product.py
Normal file
29
product_category_tax/models/product_product.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Copyright 2021 Criptomart
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
import logging
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
class ProductProduct(models.Model):
|
||||
_inherit = 'product.product'
|
||||
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
category = self.env['product.category']
|
||||
categ_id = vals.get("categ_id")
|
||||
template_id = vals.get("product_tmpl_id")
|
||||
if categ_id:
|
||||
category = category.browse(categ_id)
|
||||
vals['taxes_id'] = category.sell_tax_id
|
||||
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
|
||||
|
||||
return super(ProductProduct, self).create(vals)
|
13
product_category_tax/models/res_company.py
Normal file
13
product_category_tax/models/res_company.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Copyright 2021 Criptomart
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class Company(models.Model):
|
||||
_inherit = 'res.company'
|
||||
|
||||
use_parent_categories_to_determine_taxes = fields.Boolean(
|
||||
string="Use parent categories to determine the taxes",
|
||||
help="Use parent categories to determine the taxes if the category has no settings for the taxes.",
|
||||
)
|
13
product_category_tax/models/res_config_settings.py
Normal file
13
product_category_tax/models/res_config_settings.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Copyright 2021 Criptomart
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResConfigSettings(models.TransientModel):
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
use_parent_categories_to_determine_taxes = fields.Boolean(
|
||||
related="company_id.use_parent_categories_to_determine_taxes",
|
||||
readonly=False,
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue