mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[IMP] bi_sql_editor: black, isort, prettier
This commit is contained in:
@@ -62,7 +62,6 @@ class BiSQLView(models.Model):
|
|||||||
]
|
]
|
||||||
|
|
||||||
technical_name = fields.Char(
|
technical_name = fields.Char(
|
||||||
string="Technical Name",
|
|
||||||
required=True,
|
required=True,
|
||||||
help="Suffix of the SQL view. SQL full name will be computed and"
|
help="Suffix of the SQL view. SQL full name will be computed and"
|
||||||
" prefixed by 'x_bi_sql_view_'. Syntax should follow: "
|
" prefixed by 'x_bi_sql_view_'. Syntax should follow: "
|
||||||
@@ -71,7 +70,6 @@ class BiSQLView(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
view_name = fields.Char(
|
view_name = fields.Char(
|
||||||
string="View Name",
|
|
||||||
compute="_compute_view_name",
|
compute="_compute_view_name",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
store=True,
|
store=True,
|
||||||
@@ -79,7 +77,6 @@ class BiSQLView(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
model_name = fields.Char(
|
model_name = fields.Char(
|
||||||
string="Model Name",
|
|
||||||
compute="_compute_model_name",
|
compute="_compute_model_name",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
store=True,
|
store=True,
|
||||||
@@ -104,7 +101,6 @@ class BiSQLView(models.Model):
|
|||||||
state = fields.Selection(selection_add=_STATE_SQL_EDITOR)
|
state = fields.Selection(selection_add=_STATE_SQL_EDITOR)
|
||||||
|
|
||||||
view_order = fields.Char(
|
view_order = fields.Char(
|
||||||
string="View Order",
|
|
||||||
required=True,
|
required=True,
|
||||||
readonly=False,
|
readonly=False,
|
||||||
states={"ui_valid": [("readonly", True)]},
|
states={"ui_valid": [("readonly", True)]},
|
||||||
@@ -134,12 +130,9 @@ class BiSQLView(models.Model):
|
|||||||
states={"draft": [("readonly", False)], "sql_valid": [("readonly", False)]},
|
states={"draft": [("readonly", False)], "sql_valid": [("readonly", False)]},
|
||||||
)
|
)
|
||||||
|
|
||||||
computed_action_context = fields.Text(
|
computed_action_context = fields.Text(compute="_compute_computed_action_context")
|
||||||
compute="_compute_computed_action_context", string="Computed Action Context"
|
|
||||||
)
|
|
||||||
|
|
||||||
action_context = fields.Text(
|
action_context = fields.Text(
|
||||||
string="Action Context",
|
|
||||||
default="{}",
|
default="{}",
|
||||||
readonly=True,
|
readonly=True,
|
||||||
help="Define here a context that will be used"
|
help="Define here a context that will be used"
|
||||||
@@ -405,7 +398,8 @@ class BiSQLView(models.Model):
|
|||||||
for group in self.group_ids:
|
for group in self.group_ids:
|
||||||
res.append(
|
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,
|
"model_id": self.model_id.id,
|
||||||
"group_id": group.id,
|
"group_id": group.id,
|
||||||
"perm_read": True,
|
"perm_read": True,
|
||||||
@@ -565,9 +559,16 @@ class BiSQLView(models.Model):
|
|||||||
sql_view._refresh_size()
|
sql_view._refresh_size()
|
||||||
except ProgrammingError as e:
|
except ProgrammingError as e:
|
||||||
raise UserError(
|
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):
|
def _create_index(self):
|
||||||
for sql_view in self:
|
for sql_view in self:
|
||||||
@@ -575,8 +576,12 @@ class BiSQLView(models.Model):
|
|||||||
lambda x: x.is_index is True
|
lambda x: x.is_index is True
|
||||||
):
|
):
|
||||||
self._log_execute(
|
self._log_execute(
|
||||||
"CREATE INDEX %s ON %s (%s);"
|
"CREATE INDEX %(index_name)s ON %(view_name)s (%(field_name)s);"
|
||||||
% (sql_field.index_name, sql_view.view_name, sql_field.name)
|
% {
|
||||||
|
"index_name": sql_field.index_name,
|
||||||
|
"view_name": sql_view.view_name,
|
||||||
|
"field_name": sql_field.name,
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
def _create_model_and_fields(self):
|
def _create_model_and_fields(self):
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class BiSQLViewField(models.Model):
|
|||||||
("max", "Maximum"),
|
("max", "Maximum"),
|
||||||
]
|
]
|
||||||
|
|
||||||
name = fields.Char(string="Name", required=True, readonly=True)
|
name = fields.Char(required=True, readonly=True)
|
||||||
|
|
||||||
sql_type = fields.Char(
|
sql_type = fields.Char(
|
||||||
string="SQL Type", required=True, readonly=True, help="SQL Type in the database"
|
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(
|
is_index = fields.Boolean(
|
||||||
string="Is Index",
|
|
||||||
help="Check this box if you want to create"
|
help="Check this box if you want to create"
|
||||||
" an index on that field. This is recommended for searchable and"
|
" an index on that field. This is recommended for searchable and"
|
||||||
" groupable fields, to reduce duration",
|
" groupable fields, to reduce duration",
|
||||||
@@ -81,19 +80,17 @@ class BiSQLViewField(models.Model):
|
|||||||
" a 'group by' option in the search view",
|
" 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(
|
tree_visibility = fields.Selection(
|
||||||
string="Tree Visibility",
|
|
||||||
selection=_TREE_VISIBILITY_SELECTION,
|
selection=_TREE_VISIBILITY_SELECTION,
|
||||||
default="available",
|
default="available",
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
field_description = fields.Char(
|
field_description = fields.Char(
|
||||||
string="Field Description",
|
|
||||||
help="This will be used as the name" " of the Odoo field, displayed for users",
|
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(
|
group_operator = fields.Selection(
|
||||||
string="Group Operator",
|
|
||||||
selection=_GROUP_OPERATOR_SELECTION,
|
selection=_GROUP_OPERATOR_SELECTION,
|
||||||
help="By default, Odoo will sum the values when grouping. If you wish "
|
help="By default, Odoo will sum the values when grouping. If you wish "
|
||||||
"to alter the behaviour, choose an alternate Group Operator",
|
"to alter the behaviour, choose an alternate Group Operator",
|
||||||
|
|||||||
1
setup/bi_sql_editor/odoo/addons/bi_sql_editor
Symbolic link
1
setup/bi_sql_editor/odoo/addons/bi_sql_editor
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../../../bi_sql_editor
|
||||||
6
setup/bi_sql_editor/setup.py
Normal file
6
setup/bi_sql_editor/setup.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user