mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[ADD][12.0] account_template_active
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
# 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"
|
||||
|
||||
active = fields.Boolean("Active", default=True)
|
||||
|
||||
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(
|
||||
self.mapped("account_src_id").ids
|
||||
+ self.mapped("account_dest_id").ids
|
||||
)
|
||||
accountTemplates = AccountTemplate.browse(account_ids)
|
||||
accountTemplates.write({"active": True})
|
||||
return super().write(vals)
|
||||
Reference in New Issue
Block a user