# HG changeset patch
# User Damien Habets <damien.habets@xcg-consulting.fr>
# Date 1623247368 -7200
#      Wed Jun 09 16:02:48 2021 +0200
# Branch 13.0
# Node ID 427fc821cb05852eea42c4a13789bf438f17f0a0
# Parent  a5b115975522298d7a463766d26fb509587fecf8
Account consultation: filter account by categories

diff --git a/NEWS.rst b/NEWS.rst
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -1,6 +1,11 @@
 Changelog
 _________
 
+13.0.1.2.0
+==========
+
+* Account consultation: Filter on many account types.
+
 13.0.1.1.3
 ==========
 
diff --git a/__manifest__.py b/__manifest__.py
--- a/__manifest__.py
+++ b/__manifest__.py
@@ -20,7 +20,7 @@
 
 {
     "name": "Accounting Reports",
-    "version": "13.0.1.1.3",
+    "version": "13.0.1.2.0",
     "category": "Accounting",
     "author": "XCG Consulting",
     "website": "http://odoo.consulting/",
diff --git a/tests/test_account_report.py b/tests/test_account_report.py
--- a/tests/test_account_report.py
+++ b/tests/test_account_report.py
@@ -145,6 +145,7 @@
         aconsult_dlg = self.env["account.consultation"].create(
             aconsult_dlg_values
         )
+        self.assertTrue(aconsult_dlg.account_type_ids)
         dlg_ret = aconsult_dlg.open_general_list()
 
         # The dialog box returns an action to display accounting entries; pick
diff --git a/wizards/account_consultation.py b/wizards/account_consultation.py
--- a/wizards/account_consultation.py
+++ b/wizards/account_consultation.py
@@ -36,9 +36,10 @@
         help="The accounting account to consult.",
     )
 
-    account_type_id = fields.Many2one(
+    account_type_ids = fields.Many2many(
         comodel_name="account.account.type",
-        string="Account type",
+        string="Account categories",
+        default=lambda self: self.env["account.account.type"].search([]),
         ondelete="set null",
         help="Type used to filter selectable accounting accounts.",
     )
@@ -149,18 +150,18 @@
         required=True,
     )
 
-    @api.onchange("account_type_id", "partner_id")
+    @api.onchange("account_type_ids", "partner_id")
     def _handle_account_criteria_change(self):
         """Update selectable accounts based on criteria."""
 
-        account_type = self.account_type_id.type
+        account_types = self.account_type_ids.mapped("type")
         partner = self.partner_id
 
-        if self.account_id.internal_type != account_type:
+        if self.account_id.internal_type not in account_types:
             self.account_id = self.env["account.account"]  # Clear out.
 
         account_domain = (
-            [("internal_type", "=", account_type)] if account_type else []
+            [("internal_type", "in", account_types)] if account_types else []
         )
 
         if partner:
@@ -173,6 +174,9 @@
 
         return {"domain": {"account_id": account_domain}}
 
+    def remove_all_categories(self):
+        self.account_type_ids = False
+
     @api.onchange(
         "account_id",
         "partner_id",
@@ -337,6 +341,7 @@
 
         account = self.account_id
         partner = self.partner_id
+        categories = self.account_type_ids
         if not account and not partner:
             return [("id", "=", 0)]  # Not enough criteria.
 
@@ -347,6 +352,10 @@
         elif partner:
             aml_domain = [("partner_id", "=", partner.id)]
 
+        aml_domain.append(
+            ("account_id.internal_type", "in", categories.mapped("type"))
+        )
+
         period_states = ["draft"]
         if self.include_closed_periods:
             period_states.append("done")
diff --git a/wizards/account_consultation.xml b/wizards/account_consultation.xml
--- a/wizards/account_consultation.xml
+++ b/wizards/account_consultation.xml
@@ -15,17 +15,21 @@
 
                     <group name="account_selection_group" string="Account selection">
                         <group>
-                            <field name="account_type_id" string="Type"
-                                options="{'no_create': 1}" style="max-width: 200px;" />
                             <field name="account_id" options="{'no_create': True}"
                                 style="max-width: 400px;"
                                 attrs="{'required': [('partner_id', '=', False)]}" />
                             <field name="partner_id" options="{'no_create': True}"
                                 style="max-width: 400px;"
                                 attrs="{'required': [('account_id', '=', False)]}" />
+                            <field name="account_type_ids" nolabel="1" widget="many2many_tags"
+                                   options="{'no_create': 1}" style="max-width: 565px;" colspan="2"/>
                         </group>
                     </group>
 
+                    <button type="object"  name="remove_all_categories"
+                            class="oe_link" icon="fa-arrow-right"
+                            string="Remove all categories"/>
+
                     <group string="Transaction filters" col="6">
 
                         <group colspan="4">