diff --git a/account_financial_report/tests/test_general_ledger.py b/account_financial_report/tests/test_general_ledger.py
index 5bd2f7b77e0b..f915c653aa6c 100644
--- a/account_financial_report/tests/test_general_ledger.py
+++ b/account_financial_report/tests/test_general_ledger.py
@@ -736,19 +736,19 @@ def test_account_type_filter(self):
company_id = self.env.user.company_id
account_model = self.env["account.account"]
account = account_model.search([], limit=1)
- account_type = account.user_type_id
+ account_type = account.account_type
accounts = account_model.search(
[
("company_id", "=", company_id.id),
- ("user_type_id", "in", account_type.ids),
+ ("account_type", "=", account_type),
]
)
wizard = self.env["general.ledger.report.wizard"].create(
- {"account_type_ids": account_type, "company_id": company_id.id}
+ {"account_type": account_type, "company_id": company_id.id}
)
wizard.onchange_company_id()
self.assertEqual(wizard.account_ids, accounts)
- wizard.account_type_ids = False
- wizard._onchange_account_type_ids()
+ wizard.account_type = False
+ wizard._onchange_account_type()
self.assertEqual(wizard.account_ids, account_model)
diff --git a/account_financial_report/wizard/general_ledger_wizard.py b/account_financial_report/wizard/general_ledger_wizard.py
index 9ffc6ec3e39a..8e5172c5f376 100644
--- a/account_financial_report/wizard/general_ledger_wizard.py
+++ b/account_financial_report/wizard/general_ledger_wizard.py
@@ -45,9 +45,8 @@ class GeneralLedgerReportWizard(models.TransientModel):
)
receivable_accounts_only = fields.Boolean()
payable_accounts_only = fields.Boolean()
- account_type_ids = fields.Many2many(
- comodel_name="account.account.type",
- string="Account Types",
+ account_type = fields.Selection(
+ selection="_get_account_type_selection",
)
partner_ids = fields.Many2many(
comodel_name="res.partner",
@@ -97,6 +96,9 @@ def _get_account_move_lines_domain(self):
domain = literal_eval(self.domain) if self.domain else []
return domain
+ def _get_account_type_selection(self):
+ return self.env["account.account"]._fields["account_type"].selection
+
@api.onchange("account_code_from", "account_code_to")
def on_change_account_range(self):
if (
@@ -115,13 +117,13 @@ def on_change_account_range(self):
lambda a: a.company_id == self.company_id
)
- @api.onchange("account_type_ids")
- def _onchange_account_type_ids(self):
- if self.account_type_ids:
+ @api.onchange("account_type")
+ def _onchange_account_type(self):
+ if self.account_type:
self.account_ids = self.env["account.account"].search(
[
("company_id", "=", self.company_id.id),
- ("user_type_id", "in", self.account_type_ids.ids),
+ ("account_type", "=", self.account_type),
]
)
else:
@@ -195,8 +197,8 @@ def onchange_company_id(self):
self.account_ids = self.account_ids.filtered(
lambda a: a.company_id == self.company_id
)
- if self.company_id and self.account_type_ids:
- self._onchange_account_type_ids()
+ if self.company_id and self.account_type:
+ self._onchange_account_type()
if self.company_id and self.cost_center_ids:
self.cost_center_ids = self.cost_center_ids.filtered(
lambda c: c.company_id == self.company_id
diff --git a/account_financial_report/wizard/general_ledger_wizard_view.xml b/account_financial_report/wizard/general_ledger_wizard_view.xml
index 995a28eb2511..8cea320f2339 100644
--- a/account_financial_report/wizard/general_ledger_wizard_view.xml
+++ b/account_financial_report/wizard/general_ledger_wizard_view.xml
@@ -52,11 +52,7 @@
/>
-
+