[IMP] account_template_active: black, isort, prettier
This commit is contained in:
parent
f1526dc6c7
commit
4a630e320c
@ -15,10 +15,12 @@ class AccountAccountTemplate(models.Model):
|
||||
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 = FpaTemplate.search(
|
||||
[
|
||||
"|",
|
||||
("account_src_id", "in", self.ids),
|
||||
("account_dest_id", "in", self.ids),
|
||||
]
|
||||
)
|
||||
fpaTemplates.write({"active": False})
|
||||
return super().write(vals)
|
||||
|
@ -16,8 +16,7 @@ class AccountFiscalPositionAccountTemplate(models.Model):
|
||||
# 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
|
||||
self.mapped("account_src_id").ids + self.mapped("account_dest_id").ids
|
||||
)
|
||||
accountTemplates = AccountTemplate.browse(account_ids)
|
||||
accountTemplates.write({"active": True})
|
||||
|
@ -16,8 +16,7 @@ class AccountFiscalPositionTaxTemplate(models.Model):
|
||||
# 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
|
||||
self.mapped("tax_src_id").ids + self.mapped("tax_dest_id").ids
|
||||
)
|
||||
taxTemplates = TaxTemplate.browse(tax_ids)
|
||||
taxTemplates.write({"active": True})
|
||||
|
@ -13,10 +13,12 @@ class AccountTaxTemplate(models.Model):
|
||||
if "active" in vals and not vals.get("active"):
|
||||
# Disable account.tax.template should disable
|
||||
# account.fiscal.position.tax.template associated
|
||||
fptTemplates = FptTemplate.search([
|
||||
"|",
|
||||
("tax_src_id", "in", self.ids),
|
||||
("tax_dest_id", "in", self.ids),
|
||||
])
|
||||
fptTemplates = FptTemplate.search(
|
||||
[
|
||||
"|",
|
||||
("tax_src_id", "in", self.ids),
|
||||
("tax_dest_id", "in", self.ids),
|
||||
]
|
||||
)
|
||||
fptTemplates.write({"active": False})
|
||||
return super().write(vals)
|
||||
|
@ -12,64 +12,82 @@ class TestModule(TransactionCase):
|
||||
self.AATemplate = self.env["account.account.template"]
|
||||
self.ATTemplate = self.env["account.tax.template"]
|
||||
self.AFPTemplate = self.env["account.fiscal.position.template"]
|
||||
self.AFPATemplate =\
|
||||
self.env["account.fiscal.position.account.template"]
|
||||
self.AFPATemplate = self.env["account.fiscal.position.account.template"]
|
||||
self.AFPTTemplate = self.env["account.fiscal.position.tax.template"]
|
||||
|
||||
self.receivable_type = self.env.ref(
|
||||
"account.data_account_type_receivable")
|
||||
self.receivable_type = self.env.ref("account.data_account_type_receivable")
|
||||
|
||||
self.template = self.ACTemplate.create({
|
||||
"name": "Chart of Account",
|
||||
"bank_account_code_prefix": "BNK",
|
||||
"cash_account_code_prefix": "CSH",
|
||||
"transfer_account_code_prefix": "TRSF",
|
||||
"currency_id": self.env.ref("base.EUR").id,
|
||||
})
|
||||
self.template = self.ACTemplate.create(
|
||||
{
|
||||
"name": "Chart of Account",
|
||||
"bank_account_code_prefix": "BNK",
|
||||
"cash_account_code_prefix": "CSH",
|
||||
"transfer_account_code_prefix": "TRSF",
|
||||
"currency_id": self.env.ref("base.EUR").id,
|
||||
}
|
||||
)
|
||||
|
||||
self.account_template = self.AATemplate.create({
|
||||
"name": "Account Template",
|
||||
"code": "CODE",
|
||||
"user_type_id": self.receivable_type.id,
|
||||
"chart_template_id": self.template.id,
|
||||
})
|
||||
self.tax_template = self.ATTemplate.create({
|
||||
"name": "Tax Template",
|
||||
"chart_template_id": self.template.id,
|
||||
"amount": 10.0,
|
||||
})
|
||||
self.fiscal_position = self.AFPTemplate.create({
|
||||
"name": "Fiscal Position",
|
||||
"chart_template_id": self.template.id,
|
||||
})
|
||||
self.fiscal_position_account = self.AFPATemplate.create({
|
||||
"account_src_id": self.account_template.id,
|
||||
"account_dest_id": self.account_template.id,
|
||||
"position_id": self.fiscal_position.id,
|
||||
})
|
||||
self.fiscal_position_tax = self.AFPTTemplate.create({
|
||||
"tax_src_id": self.tax_template.id,
|
||||
"position_id": self.fiscal_position.id,
|
||||
})
|
||||
self.account_template = self.AATemplate.create(
|
||||
{
|
||||
"name": "Account Template",
|
||||
"code": "CODE",
|
||||
"user_type_id": self.receivable_type.id,
|
||||
"chart_template_id": self.template.id,
|
||||
}
|
||||
)
|
||||
self.tax_template = self.ATTemplate.create(
|
||||
{
|
||||
"name": "Tax Template",
|
||||
"chart_template_id": self.template.id,
|
||||
"amount": 10.0,
|
||||
}
|
||||
)
|
||||
self.fiscal_position = self.AFPTemplate.create(
|
||||
{
|
||||
"name": "Fiscal Position",
|
||||
"chart_template_id": self.template.id,
|
||||
}
|
||||
)
|
||||
self.fiscal_position_account = self.AFPATemplate.create(
|
||||
{
|
||||
"account_src_id": self.account_template.id,
|
||||
"account_dest_id": self.account_template.id,
|
||||
"position_id": self.fiscal_position.id,
|
||||
}
|
||||
)
|
||||
self.fiscal_position_tax = self.AFPTTemplate.create(
|
||||
{
|
||||
"tax_src_id": self.tax_template.id,
|
||||
"position_id": self.fiscal_position.id,
|
||||
}
|
||||
)
|
||||
|
||||
def test_tax_template(self):
|
||||
self.tax_template.active = False
|
||||
self.assertEqual(
|
||||
self.fiscal_position_tax.active, False,
|
||||
"Disable Tax template should disable Fiscal Position Tax")
|
||||
self.fiscal_position_tax.active,
|
||||
False,
|
||||
"Disable Tax template should disable Fiscal Position Tax",
|
||||
)
|
||||
|
||||
self.fiscal_position_tax.active = True
|
||||
self.assertEqual(
|
||||
self.tax_template.active, True,
|
||||
"Enable Fiscal Position Tax should enable Tax Template")
|
||||
self.tax_template.active,
|
||||
True,
|
||||
"Enable Fiscal Position Tax should enable Tax Template",
|
||||
)
|
||||
|
||||
def test_account_template(self):
|
||||
self.account_template.active = False
|
||||
self.assertEqual(
|
||||
self.fiscal_position_account.active, False,
|
||||
"Disable Account template should disable Fiscal Position Account")
|
||||
self.fiscal_position_account.active,
|
||||
False,
|
||||
"Disable Account template should disable Fiscal Position Account",
|
||||
)
|
||||
|
||||
self.fiscal_position_account.active = True
|
||||
self.assertEqual(
|
||||
self.account_template.active, True,
|
||||
"Enable Fiscal Position Account should enable Account Template")
|
||||
self.account_template.active,
|
||||
True,
|
||||
"Enable Fiscal Position Account should enable Account Template",
|
||||
)
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
Copyright (C) 2018 - Today: GRAP (http://www.grap.coop)
|
||||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
@ -15,7 +15,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
<attribute name="decoration-muted">not active</attribute>
|
||||
</xpath>
|
||||
<field name="user_type_id" position="after">
|
||||
<field name="active" widget="boolean_toggle"/>
|
||||
<field name="active" widget="boolean_toggle" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@ -25,7 +25,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
<field name="inherit_id" ref="account.view_account_template_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="chart_template_id" position="after">
|
||||
<field name="active"/>
|
||||
<field name="active" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
Copyright (C) 2018 - Today: GRAP (http://www.grap.coop)
|
||||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
@ -15,7 +15,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
<attribute name="decoration-muted">not active</attribute>
|
||||
</xpath>
|
||||
<field name="name" position="after">
|
||||
<field name="active" widget="boolean_toggle"/>
|
||||
<field name="active" widget="boolean_toggle" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
@ -25,27 +25,42 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
<field name="inherit_id" ref="account.view_account_position_template_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="chart_template_id" position="after">
|
||||
<field name="active"/>
|
||||
<field name="active" />
|
||||
</field>
|
||||
<xpath expr="//field[@name='tax_ids']/tree" position="attributes">
|
||||
<attribute name="decoration-muted">not active</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='tax_ids']/tree/field[@name='tax_dest_id']" position="after">
|
||||
<field name="active" widget="boolean_toggle"/>
|
||||
<xpath
|
||||
expr="//field[@name='tax_ids']/tree/field[@name='tax_dest_id']"
|
||||
position="after"
|
||||
>
|
||||
<field name="active" widget="boolean_toggle" />
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='tax_ids']/form/field[@name='tax_dest_id']" position="after">
|
||||
<field name="active"/>
|
||||
<xpath
|
||||
expr="//field[@name='tax_ids']/form/field[@name='tax_dest_id']"
|
||||
position="after"
|
||||
>
|
||||
<field name="active" />
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='account_ids']/tree/field[@name='account_dest_id']" position="after">
|
||||
<field name="active" widget="boolean_toggle"/>
|
||||
<xpath
|
||||
expr="//field[@name='account_ids']/tree/field[@name='account_dest_id']"
|
||||
position="after"
|
||||
>
|
||||
<field name="active" widget="boolean_toggle" />
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='account_ids']/form/field[@name='account_dest_id']" position="after">
|
||||
<field name="active"/>
|
||||
<xpath
|
||||
expr="//field[@name='account_ids']/form/field[@name='account_dest_id']"
|
||||
position="after"
|
||||
>
|
||||
<field name="active" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="account.action_account_fiscal_position_template_form" model="ir.actions.act_window">
|
||||
<record
|
||||
id="account.action_account_fiscal_position_template_form"
|
||||
model="ir.actions.act_window"
|
||||
>
|
||||
<field name="context">{"active_test": False}</field>
|
||||
</record>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
Copyright (C) 2020 - Today: GRAP (http://www.grap.coop)
|
||||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
|
||||
@ -8,13 +8,13 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
<record id="view_account_tax_template_tree" model="ir.ui.view">
|
||||
<field name="model">account.tax.template</field>
|
||||
<field name="inherit_id" ref="account.view_account_tax_template_tree"/>
|
||||
<field name="inherit_id" ref="account.view_account_tax_template_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//tree" position="attributes">
|
||||
<attribute name="decoration-muted">not active</attribute>
|
||||
</xpath>
|
||||
<field name="description" position="after">
|
||||
<field name="active" widget="boolean_toggle"/>
|
||||
<field name="active" widget="boolean_toggle" />
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
Loading…
Reference in New Issue
Block a user