2020-05-04 15:17:28 +02:00
|
|
|
# Copyright (C) 2018-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 AccountFiscalPositionAccountTemplate(models.Model):
|
|
|
|
_inherit = "account.fiscal.position.account.template"
|
|
|
|
|
2022-11-03 23:25:22 +01:00
|
|
|
active = fields.Boolean(default=True)
|
2020-05-04 15:17:28 +02:00
|
|
|
|
|
|
|
def write(self, vals):
|
|
|
|
AccountTemplate = self.env["account.account.template"]
|
|
|
|
if vals.get("active", False):
|
|
|
|
# enable account.fiscal.position.account.template should enable
|
|
|
|
# related account.account.template
|
|
|
|
account_ids = set(
|
2021-05-18 11:52:53 +02:00
|
|
|
self.mapped("account_src_id").ids + self.mapped("account_dest_id").ids
|
2020-05-04 15:17:28 +02:00
|
|
|
)
|
|
|
|
accountTemplates = AccountTemplate.browse(account_ids)
|
|
|
|
accountTemplates.write({"active": True})
|
|
|
|
return super().write(vals)
|