2
0
account-financial-tools/account_template_active/models/account_fiscal_position_tax_template.py

24 lines
866 B
Python
Raw Normal View History

2020-05-04 15:17:28 +02:00
# Copyright (C) 2019-Today GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class AccountFiscalPositionTaxTemplate(models.Model):
_inherit = "account.fiscal.position.tax.template"
active = fields.Boolean(default=True)
2020-05-04 15:17:28 +02:00
def write(self, vals):
TaxTemplate = self.env["account.tax.template"]
if vals.get("active", False):
# enable account.fiscal.position.tax.template should enable
# related account.tax.template
tax_ids = set(
self.mapped("tax_src_id").ids + self.mapped("tax_dest_id").ids
2020-05-04 15:17:28 +02:00
)
taxTemplates = TaxTemplate.browse(tax_ids)
taxTemplates.write({"active": True})
return super().write(vals)