2
0
account-financial-tools/account_template_active/models/account_account_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

27 lines
959 B
Python

# Copyright (C) 2015 - 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 AccountAccountTemplate(models.Model):
_inherit = "account.account.template"
active = fields.Boolean(default=True)
def write(self, vals):
FpaTemplate = self.env["account.fiscal.position.account.template"]
if "active" in vals and not vals.get("active"):
# Disable account.account.template should disable
# account.fiscal.position.account.template associated
fpaTemplates = FpaTemplate.search(
[
"|",
("account_src_id", "in", self.ids),
("account_dest_id", "in", self.ids),
]
)
fpaTemplates.write({"active": False})
return super().write(vals)