[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"):
|
if "active" in vals and not vals.get("active"):
|
||||||
# Disable account.account.template should disable
|
# Disable account.account.template should disable
|
||||||
# account.fiscal.position.account.template associated
|
# account.fiscal.position.account.template associated
|
||||||
fpaTemplates = FpaTemplate.search([
|
fpaTemplates = FpaTemplate.search(
|
||||||
|
[
|
||||||
"|",
|
"|",
|
||||||
("account_src_id", "in", self.ids),
|
("account_src_id", "in", self.ids),
|
||||||
("account_dest_id", "in", self.ids),
|
("account_dest_id", "in", self.ids),
|
||||||
])
|
]
|
||||||
|
)
|
||||||
fpaTemplates.write({"active": False})
|
fpaTemplates.write({"active": False})
|
||||||
return super().write(vals)
|
return super().write(vals)
|
||||||
|
@ -16,8 +16,7 @@ class AccountFiscalPositionAccountTemplate(models.Model):
|
|||||||
# enable account.fiscal.position.account.template should enable
|
# enable account.fiscal.position.account.template should enable
|
||||||
# related account.account.template
|
# related account.account.template
|
||||||
account_ids = set(
|
account_ids = set(
|
||||||
self.mapped("account_src_id").ids
|
self.mapped("account_src_id").ids + self.mapped("account_dest_id").ids
|
||||||
+ self.mapped("account_dest_id").ids
|
|
||||||
)
|
)
|
||||||
accountTemplates = AccountTemplate.browse(account_ids)
|
accountTemplates = AccountTemplate.browse(account_ids)
|
||||||
accountTemplates.write({"active": True})
|
accountTemplates.write({"active": True})
|
||||||
|
@ -16,8 +16,7 @@ class AccountFiscalPositionTaxTemplate(models.Model):
|
|||||||
# enable account.fiscal.position.tax.template should enable
|
# enable account.fiscal.position.tax.template should enable
|
||||||
# related account.tax.template
|
# related account.tax.template
|
||||||
tax_ids = set(
|
tax_ids = set(
|
||||||
self.mapped("tax_src_id").ids
|
self.mapped("tax_src_id").ids + self.mapped("tax_dest_id").ids
|
||||||
+ self.mapped("tax_dest_id").ids
|
|
||||||
)
|
)
|
||||||
taxTemplates = TaxTemplate.browse(tax_ids)
|
taxTemplates = TaxTemplate.browse(tax_ids)
|
||||||
taxTemplates.write({"active": True})
|
taxTemplates.write({"active": True})
|
||||||
|
@ -13,10 +13,12 @@ class AccountTaxTemplate(models.Model):
|
|||||||
if "active" in vals and not vals.get("active"):
|
if "active" in vals and not vals.get("active"):
|
||||||
# Disable account.tax.template should disable
|
# Disable account.tax.template should disable
|
||||||
# account.fiscal.position.tax.template associated
|
# account.fiscal.position.tax.template associated
|
||||||
fptTemplates = FptTemplate.search([
|
fptTemplates = FptTemplate.search(
|
||||||
|
[
|
||||||
"|",
|
"|",
|
||||||
("tax_src_id", "in", self.ids),
|
("tax_src_id", "in", self.ids),
|
||||||
("tax_dest_id", "in", self.ids),
|
("tax_dest_id", "in", self.ids),
|
||||||
])
|
]
|
||||||
|
)
|
||||||
fptTemplates.write({"active": False})
|
fptTemplates.write({"active": False})
|
||||||
return super().write(vals)
|
return super().write(vals)
|
||||||
|
@ -12,64 +12,82 @@ class TestModule(TransactionCase):
|
|||||||
self.AATemplate = self.env["account.account.template"]
|
self.AATemplate = self.env["account.account.template"]
|
||||||
self.ATTemplate = self.env["account.tax.template"]
|
self.ATTemplate = self.env["account.tax.template"]
|
||||||
self.AFPTemplate = self.env["account.fiscal.position.template"]
|
self.AFPTemplate = self.env["account.fiscal.position.template"]
|
||||||
self.AFPATemplate =\
|
self.AFPATemplate = self.env["account.fiscal.position.account.template"]
|
||||||
self.env["account.fiscal.position.account.template"]
|
|
||||||
self.AFPTTemplate = self.env["account.fiscal.position.tax.template"]
|
self.AFPTTemplate = self.env["account.fiscal.position.tax.template"]
|
||||||
|
|
||||||
self.receivable_type = self.env.ref(
|
self.receivable_type = self.env.ref("account.data_account_type_receivable")
|
||||||
"account.data_account_type_receivable")
|
|
||||||
|
|
||||||
self.template = self.ACTemplate.create({
|
self.template = self.ACTemplate.create(
|
||||||
|
{
|
||||||
"name": "Chart of Account",
|
"name": "Chart of Account",
|
||||||
"bank_account_code_prefix": "BNK",
|
"bank_account_code_prefix": "BNK",
|
||||||
"cash_account_code_prefix": "CSH",
|
"cash_account_code_prefix": "CSH",
|
||||||
"transfer_account_code_prefix": "TRSF",
|
"transfer_account_code_prefix": "TRSF",
|
||||||
"currency_id": self.env.ref("base.EUR").id,
|
"currency_id": self.env.ref("base.EUR").id,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
self.account_template = self.AATemplate.create({
|
self.account_template = self.AATemplate.create(
|
||||||
|
{
|
||||||
"name": "Account Template",
|
"name": "Account Template",
|
||||||
"code": "CODE",
|
"code": "CODE",
|
||||||
"user_type_id": self.receivable_type.id,
|
"user_type_id": self.receivable_type.id,
|
||||||
"chart_template_id": self.template.id,
|
"chart_template_id": self.template.id,
|
||||||
})
|
}
|
||||||
self.tax_template = self.ATTemplate.create({
|
)
|
||||||
|
self.tax_template = self.ATTemplate.create(
|
||||||
|
{
|
||||||
"name": "Tax Template",
|
"name": "Tax Template",
|
||||||
"chart_template_id": self.template.id,
|
"chart_template_id": self.template.id,
|
||||||
"amount": 10.0,
|
"amount": 10.0,
|
||||||
})
|
}
|
||||||
self.fiscal_position = self.AFPTemplate.create({
|
)
|
||||||
|
self.fiscal_position = self.AFPTemplate.create(
|
||||||
|
{
|
||||||
"name": "Fiscal Position",
|
"name": "Fiscal Position",
|
||||||
"chart_template_id": self.template.id,
|
"chart_template_id": self.template.id,
|
||||||
})
|
}
|
||||||
self.fiscal_position_account = self.AFPATemplate.create({
|
)
|
||||||
|
self.fiscal_position_account = self.AFPATemplate.create(
|
||||||
|
{
|
||||||
"account_src_id": self.account_template.id,
|
"account_src_id": self.account_template.id,
|
||||||
"account_dest_id": self.account_template.id,
|
"account_dest_id": self.account_template.id,
|
||||||
"position_id": self.fiscal_position.id,
|
"position_id": self.fiscal_position.id,
|
||||||
})
|
}
|
||||||
self.fiscal_position_tax = self.AFPTTemplate.create({
|
)
|
||||||
|
self.fiscal_position_tax = self.AFPTTemplate.create(
|
||||||
|
{
|
||||||
"tax_src_id": self.tax_template.id,
|
"tax_src_id": self.tax_template.id,
|
||||||
"position_id": self.fiscal_position.id,
|
"position_id": self.fiscal_position.id,
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
def test_tax_template(self):
|
def test_tax_template(self):
|
||||||
self.tax_template.active = False
|
self.tax_template.active = False
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.fiscal_position_tax.active, False,
|
self.fiscal_position_tax.active,
|
||||||
"Disable Tax template should disable Fiscal Position Tax")
|
False,
|
||||||
|
"Disable Tax template should disable Fiscal Position Tax",
|
||||||
|
)
|
||||||
|
|
||||||
self.fiscal_position_tax.active = True
|
self.fiscal_position_tax.active = True
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.tax_template.active, True,
|
self.tax_template.active,
|
||||||
"Enable Fiscal Position Tax should enable Tax Template")
|
True,
|
||||||
|
"Enable Fiscal Position Tax should enable Tax Template",
|
||||||
|
)
|
||||||
|
|
||||||
def test_account_template(self):
|
def test_account_template(self):
|
||||||
self.account_template.active = False
|
self.account_template.active = False
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.fiscal_position_account.active, False,
|
self.fiscal_position_account.active,
|
||||||
"Disable Account template should disable Fiscal Position Account")
|
False,
|
||||||
|
"Disable Account template should disable Fiscal Position Account",
|
||||||
|
)
|
||||||
|
|
||||||
self.fiscal_position_account.active = True
|
self.fiscal_position_account.active = True
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.account_template.active, True,
|
self.account_template.active,
|
||||||
"Enable Fiscal Position Account should enable Account Template")
|
True,
|
||||||
|
"Enable Fiscal Position Account should enable Account Template",
|
||||||
|
)
|
||||||
|
@ -30,22 +30,37 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|||||||
<xpath expr="//field[@name='tax_ids']/tree" position="attributes">
|
<xpath expr="//field[@name='tax_ids']/tree" position="attributes">
|
||||||
<attribute name="decoration-muted">not active</attribute>
|
<attribute name="decoration-muted">not active</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//field[@name='tax_ids']/tree/field[@name='tax_dest_id']" position="after">
|
<xpath
|
||||||
|
expr="//field[@name='tax_ids']/tree/field[@name='tax_dest_id']"
|
||||||
|
position="after"
|
||||||
|
>
|
||||||
<field name="active" widget="boolean_toggle" />
|
<field name="active" widget="boolean_toggle" />
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//field[@name='tax_ids']/form/field[@name='tax_dest_id']" position="after">
|
<xpath
|
||||||
|
expr="//field[@name='tax_ids']/form/field[@name='tax_dest_id']"
|
||||||
|
position="after"
|
||||||
|
>
|
||||||
<field name="active" />
|
<field name="active" />
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//field[@name='account_ids']/tree/field[@name='account_dest_id']" position="after">
|
<xpath
|
||||||
|
expr="//field[@name='account_ids']/tree/field[@name='account_dest_id']"
|
||||||
|
position="after"
|
||||||
|
>
|
||||||
<field name="active" widget="boolean_toggle" />
|
<field name="active" widget="boolean_toggle" />
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//field[@name='account_ids']/form/field[@name='account_dest_id']" position="after">
|
<xpath
|
||||||
|
expr="//field[@name='account_ids']/form/field[@name='account_dest_id']"
|
||||||
|
position="after"
|
||||||
|
>
|
||||||
<field name="active" />
|
<field name="active" />
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</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>
|
<field name="context">{"active_test": False}</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user