From 899ff8086a0fe96ef36dc09f559855372cb1e747 Mon Sep 17 00:00:00 2001 From: mariadforgeflow Date: Mon, 13 Dec 2021 09:07:59 +0100 Subject: [PATCH] [IMP] bi_sql_editor: black, isort, prettier --- bi_sql_editor/models/bi_sql_view.py | 33 +++++++++++++---------- bi_sql_editor/models/bi_sql_view_field.py | 10 +++---- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/bi_sql_editor/models/bi_sql_view.py b/bi_sql_editor/models/bi_sql_view.py index 6c5627f76..5a5707410 100644 --- a/bi_sql_editor/models/bi_sql_view.py +++ b/bi_sql_editor/models/bi_sql_view.py @@ -62,7 +62,6 @@ class BiSQLView(models.Model): ] technical_name = fields.Char( - string="Technical Name", required=True, help="Suffix of the SQL view. SQL full name will be computed and" " prefixed by 'x_bi_sql_view_'. Syntax should follow: " @@ -71,7 +70,6 @@ class BiSQLView(models.Model): ) view_name = fields.Char( - string="View Name", compute="_compute_view_name", readonly=True, store=True, @@ -79,7 +77,6 @@ class BiSQLView(models.Model): ) model_name = fields.Char( - string="Model Name", compute="_compute_model_name", readonly=True, store=True, @@ -104,7 +101,6 @@ class BiSQLView(models.Model): state = fields.Selection(selection_add=_STATE_SQL_EDITOR) view_order = fields.Char( - string="View Order", required=True, readonly=False, states={"ui_valid": [("readonly", True)]}, @@ -134,12 +130,9 @@ class BiSQLView(models.Model): states={"draft": [("readonly", False)], "sql_valid": [("readonly", False)]}, ) - computed_action_context = fields.Text( - compute="_compute_computed_action_context", string="Computed Action Context" - ) + computed_action_context = fields.Text(compute="_compute_computed_action_context") action_context = fields.Text( - string="Action Context", default="{}", readonly=True, help="Define here a context that will be used" @@ -405,7 +398,8 @@ class BiSQLView(models.Model): for group in self.group_ids: res.append( { - "name": _("%s Access %s") % (self.model_name, group.full_name), + "name": _("%(model_name)s Access %(full_name)s") + % {"model_name": self.model_name, "full_name": group.full_name}, "model_id": self.model_id.id, "group_id": group.id, "perm_read": True, @@ -565,9 +559,16 @@ class BiSQLView(models.Model): sql_view._refresh_size() except ProgrammingError as e: raise UserError( - _("SQL Error while creating %s VIEW %s :\n %s") - % (sql_view.materialized_text, sql_view.view_name, str(e)) - ) + _( + "SQL Error while creating %(materialized_text)s" + " VIEW %(view_name)s :\n %(error)s" + ) + % { + "materialized_text": sql_view.materialized_text, + "view_name": sql_view.view_name, + "error": str(e), + } + ) from e def _create_index(self): for sql_view in self: @@ -575,8 +576,12 @@ class BiSQLView(models.Model): lambda x: x.is_index is True ): self._log_execute( - "CREATE INDEX %s ON %s (%s);" - % (sql_field.index_name, sql_view.view_name, sql_field.name) + "CREATE INDEX %(index_name)s ON %(view_name)s (%(field_name)s);" + % { + "index_name": sql_field.index_name, + "view_name": sql_view.view_name, + "field_name": sql_field.name, + } ) def _create_model_and_fields(self): diff --git a/bi_sql_editor/models/bi_sql_view_field.py b/bi_sql_editor/models/bi_sql_view_field.py index 1689f7a32..8531ce2f7 100644 --- a/bi_sql_editor/models/bi_sql_view_field.py +++ b/bi_sql_editor/models/bi_sql_view_field.py @@ -56,7 +56,7 @@ class BiSQLViewField(models.Model): ("max", "Maximum"), ] - name = fields.Char(string="Name", required=True, readonly=True) + name = fields.Char(required=True, readonly=True) sql_type = fields.Char( string="SQL Type", required=True, readonly=True, help="SQL Type in the database" @@ -69,7 +69,6 @@ class BiSQLViewField(models.Model): ) is_index = fields.Boolean( - string="Is Index", help="Check this box if you want to create" " an index on that field. This is recommended for searchable and" " groupable fields, to reduce duration", @@ -81,19 +80,17 @@ class BiSQLViewField(models.Model): " a 'group by' option in the search view", ) - index_name = fields.Char(string="Index Name", compute="_compute_index_name") + index_name = fields.Char(ompute="_compute_index_name") - graph_type = fields.Selection(string="Graph Type", selection=_GRAPH_TYPE_SELECTION) + graph_type = fields.Selection(selection=_GRAPH_TYPE_SELECTION) tree_visibility = fields.Selection( - string="Tree Visibility", selection=_TREE_VISIBILITY_SELECTION, default="available", required=True, ) field_description = fields.Char( - string="Field Description", help="This will be used as the name" " of the Odoo field, displayed for users", ) @@ -122,7 +119,6 @@ class BiSQLViewField(models.Model): ) group_operator = fields.Selection( - string="Group Operator", selection=_GROUP_OPERATOR_SELECTION, help="By default, Odoo will sum the values when grouping. If you wish " "to alter the behaviour, choose an alternate Group Operator",