From 53d0a053f6e58142f6efefcc013f34796e328772 Mon Sep 17 00:00:00 2001 From: GuillemCForgeFlow Date: Tue, 4 Jun 2024 17:24:27 +0200 Subject: [PATCH] [IMP]bi_sql_editor: many2one fields clickable on the list view if setting is enabled --- bi_sql_editor/models/bi_sql_view_field.py | 15 +++++++++++++-- bi_sql_editor/readme/CONFIGURE.rst | 3 ++- bi_sql_editor/views/view_bi_sql_view.xml | 4 ++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/bi_sql_editor/models/bi_sql_view_field.py b/bi_sql_editor/models/bi_sql_view_field.py index 89800819d6..bde981288f 100644 --- a/bi_sql_editor/models/bi_sql_view_field.py +++ b/bi_sql_editor/models/bi_sql_view_field.py @@ -74,6 +74,12 @@ class BiSQLViewField(models.Model): " a 'group by' option in the search view", ) + is_many2one_clickable = fields.Boolean( + default=True, + help="If the field is of type Many2one and the option is enabled, the" + "field will be clickable on the list view.", + ) + index_name = fields.Char(string="Index Name", compute="_compute_index_name") graph_type = fields.Selection(string="Graph Type", selection=_GRAPH_TYPE_SELECTION) @@ -207,8 +213,13 @@ def _prepare_tree_field(self): self.ensure_one() res = "" if self.field_description and self.tree_visibility != "unavailable": - res = """""".format( - self.name, self.tree_visibility == "hidden" and 'invisible="1"' or "" + res = """""".format( + self.name, + self.tree_visibility == "hidden" and 'invisible="1"' or "", + self.ttype == "many2one" + and self.is_many2one_clickable + and 'widget="many2one"' + or "", ) return res diff --git a/bi_sql_editor/readme/CONFIGURE.rst b/bi_sql_editor/readme/CONFIGURE.rst index e528a24eea..647b9a91ed 100644 --- a/bi_sql_editor/readme/CONFIGURE.rst +++ b/bi_sql_editor/readme/CONFIGURE.rst @@ -17,7 +17,8 @@ To configure this module, you need to: * Once the sql request checked, the module analyses the column of the view, and propose field mapping. For each field, you can decide to create an index and set if it will be displayed on the pivot graph as a column, a row or a - measure. + measure. On top of that, if the field is of type Many2one, you can also + select the option to be clickable on the list view. .. figure:: ../static/description/03_field_mapping.png :width: 800 px diff --git a/bi_sql_editor/views/view_bi_sql_view.xml b/bi_sql_editor/views/view_bi_sql_view.xml index 5dc41bba6a..6bfa2b7ddf 100644 --- a/bi_sql_editor/views/view_bi_sql_view.xml +++ b/bi_sql_editor/views/view_bi_sql_view.xml @@ -162,6 +162,10 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). ('field_description', '!=', False), ('ttype', '=', 'many2one')]}" /> +