From 4a630e320cc5c569badd765b260b449611b8b596 Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Tue, 18 May 2021 11:52:53 +0200 Subject: [PATCH] [IMP] account_template_active: black, isort, prettier --- .../models/account_account_template.py | 12 +- ...ccount_fiscal_position_account_template.py | 3 +- .../account_fiscal_position_tax_template.py | 3 +- .../models/account_tax_template.py | 12 +- account_template_active/tests/test_module.py | 104 ++++++++++-------- .../views/view_account_account_template.xml | 6 +- .../view_account_fiscal_position_template.xml | 39 +++++-- .../views/view_account_tax_template.xml | 6 +- 8 files changed, 110 insertions(+), 75 deletions(-) diff --git a/account_template_active/models/account_account_template.py b/account_template_active/models/account_account_template.py index 9bff96f1..2ca7283a 100644 --- a/account_template_active/models/account_account_template.py +++ b/account_template_active/models/account_account_template.py @@ -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) diff --git a/account_template_active/models/account_fiscal_position_account_template.py b/account_template_active/models/account_fiscal_position_account_template.py index d2355022..27261c25 100644 --- a/account_template_active/models/account_fiscal_position_account_template.py +++ b/account_template_active/models/account_fiscal_position_account_template.py @@ -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}) diff --git a/account_template_active/models/account_fiscal_position_tax_template.py b/account_template_active/models/account_fiscal_position_tax_template.py index ad8bf0f6..9c3a61e7 100644 --- a/account_template_active/models/account_fiscal_position_tax_template.py +++ b/account_template_active/models/account_fiscal_position_tax_template.py @@ -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}) diff --git a/account_template_active/models/account_tax_template.py b/account_template_active/models/account_tax_template.py index 8353573e..f3e001af 100644 --- a/account_template_active/models/account_tax_template.py +++ b/account_template_active/models/account_tax_template.py @@ -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) diff --git a/account_template_active/tests/test_module.py b/account_template_active/tests/test_module.py index d2d40e84..81a4e9a3 100644 --- a/account_template_active/tests/test_module.py +++ b/account_template_active/tests/test_module.py @@ -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", + ) diff --git a/account_template_active/views/view_account_account_template.xml b/account_template_active/views/view_account_account_template.xml index 0b69480d..1daeebb7 100644 --- a/account_template_active/views/view_account_account_template.xml +++ b/account_template_active/views/view_account_account_template.xml @@ -1,4 +1,4 @@ - +