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:
committed by
Stefan Rijnhart
parent
5868eebbcd
commit
fd755e3984
24
account_template_active/models/account_account_template.py
Normal file
24
account_template_active/models/account_account_template.py
Normal file
@@ -0,0 +1,24 @@
|
||||
# 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(string="Active", 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)
|
||||
Reference in New Issue
Block a user