mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[MIG] bi_sql_editor: Migration to 17.0
This commit is contained in:
@@ -59,8 +59,6 @@ class BiSQLView(models.Model):
|
||||
is_materialized = fields.Boolean(
|
||||
string="Is Materialized View",
|
||||
default=True,
|
||||
readonly=True,
|
||||
states={"draft": [("readonly", False)], "sql_valid": [("readonly", False)]},
|
||||
)
|
||||
|
||||
materialized_text = fields.Char(compute="_compute_materialized_text", store=True)
|
||||
@@ -75,8 +73,6 @@ class BiSQLView(models.Model):
|
||||
|
||||
view_order = fields.Char(
|
||||
required=True,
|
||||
readonly=False,
|
||||
states={"ui_valid": [("readonly", True)]},
|
||||
default="pivot,graph,tree",
|
||||
help="Comma-separated text. Possible values:" ' "graph", "pivot" or "tree"',
|
||||
)
|
||||
@@ -93,28 +89,20 @@ class BiSQLView(models.Model):
|
||||
domain_force = fields.Text(
|
||||
string="Extra Rule Definition",
|
||||
default="[]",
|
||||
readonly=True,
|
||||
help="Define here access restriction to data.\n"
|
||||
" Take care to use field name prefixed by 'x_'."
|
||||
" A global 'ir.rule' will be created."
|
||||
" A typical Multi Company rule is for exemple \n"
|
||||
" ['|', ('x_company_id','child_of', [user.company_id.id]),"
|
||||
"('x_company_id','=',False)].",
|
||||
states={"draft": [("readonly", False)], "sql_valid": [("readonly", False)]},
|
||||
)
|
||||
|
||||
computed_action_context = fields.Text(compute="_compute_computed_action_context")
|
||||
|
||||
action_context = fields.Text(
|
||||
default="{}",
|
||||
readonly=True,
|
||||
help="Define here a context that will be used"
|
||||
" by default, when creating the action.",
|
||||
states={
|
||||
"draft": [("readonly", False)],
|
||||
"sql_valid": [("readonly", False)],
|
||||
"model_valid": [("readonly", False)],
|
||||
},
|
||||
)
|
||||
|
||||
bi_sql_view_field_ids = fields.One2many(
|
||||
@@ -161,12 +149,6 @@ class BiSQLView(models.Model):
|
||||
|
||||
rule_id = fields.Many2one(string="Odoo Rule", comodel_name="ir.rule", readonly=True)
|
||||
|
||||
group_ids = fields.Many2many(
|
||||
comodel_name="res.groups",
|
||||
readonly=True,
|
||||
states={"draft": [("readonly", False)], "sql_valid": [("readonly", False)]},
|
||||
)
|
||||
|
||||
sequence = fields.Integer(string="sequence")
|
||||
|
||||
# Constrains Section
|
||||
@@ -522,8 +504,7 @@ class BiSQLView(models.Model):
|
||||
def _drop_view(self):
|
||||
for sql_view in self:
|
||||
self._log_execute(
|
||||
"DROP %s VIEW IF EXISTS %s"
|
||||
% (sql_view.materialized_text, sql_view.view_name)
|
||||
f"DROP {sql_view.materialized_text} VIEW IF EXISTS {sql_view.view_name}"
|
||||
)
|
||||
sql_view.size = False
|
||||
|
||||
@@ -552,12 +533,7 @@ class BiSQLView(models.Model):
|
||||
lambda x: x.is_index is True
|
||||
):
|
||||
self._log_execute(
|
||||
"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,
|
||||
}
|
||||
f"CREATE INDEX {sql_field.index_name} ON {sql_view.view_name} ({sql_field.name});"
|
||||
)
|
||||
|
||||
def _create_model_and_fields(self):
|
||||
@@ -639,7 +615,7 @@ class BiSQLView(models.Model):
|
||||
field_ids = []
|
||||
for column in columns:
|
||||
existing_field = self.bi_sql_view_field_ids.filtered(
|
||||
lambda x: x.name == column[1]
|
||||
lambda x, c=column: x.name == c[1]
|
||||
)
|
||||
if existing_field:
|
||||
# Update existing field
|
||||
|
||||
@@ -76,34 +76,29 @@ class BiSQLViewField(models.Model):
|
||||
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",
|
||||
states={"model_valid": [("readonly", True)], "ui_valid": [("readonly", True)]},
|
||||
)
|
||||
|
||||
is_group_by = fields.Boolean(
|
||||
string="Is Group by",
|
||||
help="Check this box if you want to create"
|
||||
" a 'group by' option in the search view",
|
||||
states={"ui_valid": [("readonly", True)]},
|
||||
)
|
||||
|
||||
index_name = fields.Char(compute="_compute_index_name")
|
||||
|
||||
graph_type = fields.Selection(
|
||||
selection=_GRAPH_TYPE_SELECTION,
|
||||
states={"ui_valid": [("readonly", True)]},
|
||||
)
|
||||
|
||||
tree_visibility = fields.Selection(
|
||||
selection=_TREE_VISIBILITY_SELECTION,
|
||||
default="available",
|
||||
required=True,
|
||||
states={"ui_valid": [("readonly", True)]},
|
||||
)
|
||||
|
||||
field_description = fields.Char(
|
||||
help="This will be used as the name of the Odoo field, displayed for users",
|
||||
required=True,
|
||||
states={"model_valid": [("readonly", True)], "ui_valid": [("readonly", True)]},
|
||||
)
|
||||
|
||||
ttype = fields.Selection(
|
||||
@@ -113,7 +108,6 @@ class BiSQLViewField(models.Model):
|
||||
" Odoo field that will be created. Keep empty if you don't want to"
|
||||
" create a new field. If empty, this field will not be displayed"
|
||||
" neither available for search or group by function",
|
||||
states={"model_valid": [("readonly", True)], "ui_valid": [("readonly", True)]},
|
||||
)
|
||||
|
||||
selection = fields.Text(
|
||||
@@ -123,28 +117,24 @@ class BiSQLViewField(models.Model):
|
||||
" List of options, specified as a Python expression defining a list of"
|
||||
" (key, label) pairs. For example:"
|
||||
" [('blue','Blue'), ('yellow','Yellow')]",
|
||||
states={"model_valid": [("readonly", True)], "ui_valid": [("readonly", True)]},
|
||||
)
|
||||
|
||||
many2one_model_id = fields.Many2one(
|
||||
comodel_name="ir.model",
|
||||
string="Model",
|
||||
help="For 'Many2one' Odoo field.\n" " Comodel of the field.",
|
||||
states={"model_valid": [("readonly", True)], "ui_valid": [("readonly", True)]},
|
||||
)
|
||||
|
||||
group_operator = fields.Selection(
|
||||
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",
|
||||
states={"model_valid": [("readonly", True)], "ui_valid": [("readonly", True)]},
|
||||
)
|
||||
|
||||
field_context = fields.Char(
|
||||
default="{}",
|
||||
help="Context value that will be inserted for this field in all the views."
|
||||
" Important note : please write a context with single quote.",
|
||||
states={"ui_valid": [("readonly", True)]},
|
||||
)
|
||||
|
||||
# Constrains Section
|
||||
@@ -255,7 +245,7 @@ class BiSQLViewField(models.Model):
|
||||
return ""
|
||||
visibility_text = ""
|
||||
if self.tree_visibility == "invisible":
|
||||
visibility_text = 'invisible="1"'
|
||||
visibility_text = 'column_invisible="1"'
|
||||
elif self.tree_visibility == "optional_hide":
|
||||
visibility_text = 'optional="hide"'
|
||||
elif self.tree_visibility == "optional_show":
|
||||
|
||||
Reference in New Issue
Block a user