2
0
account-financial-tools/account_template_active/models/account_fiscal_position_tax_template.py
Sylvain LE GAL da416248ac [MIG] account_template_active from 14.0 to 16.0
- use new web_ribbon widget to display archived items on form views
- change inheritance from account to account_usability regarding views that disappeared in V16
2023-01-19 17:24:20 +01:00

24 lines
866 B
Python

# 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)
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
)
taxTemplates = TaxTemplate.browse(tax_ids)
taxTemplates.write({"active": True})
return super().write(vals)