mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
pre-commit
This commit is contained in:
@@ -320,7 +320,11 @@ class BveView(models.Model):
|
||||
try:
|
||||
with self.env.cr.savepoint():
|
||||
self.env.cr.execute(
|
||||
"CREATE or REPLACE VIEW %s as (%s)", (AsIs(view_name), AsIs(query),)
|
||||
"CREATE or REPLACE VIEW %s as (%s)",
|
||||
(
|
||||
AsIs(view_name),
|
||||
AsIs(query),
|
||||
),
|
||||
)
|
||||
except Exception as e:
|
||||
raise UserError(
|
||||
|
||||
@@ -57,8 +57,16 @@ class BveViewLine(models.Model):
|
||||
def _constrains_unique_fields_check(self):
|
||||
seen = set()
|
||||
for line in self.mapped("bve_view_id.field_ids"):
|
||||
if (line.table_alias, line.field_id.id,) not in seen:
|
||||
seen.add((line.table_alias, line.field_id.id,))
|
||||
if (
|
||||
line.table_alias,
|
||||
line.field_id.id,
|
||||
) not in seen:
|
||||
seen.add(
|
||||
(
|
||||
line.table_alias,
|
||||
line.field_id.id,
|
||||
)
|
||||
)
|
||||
else:
|
||||
raise ValidationError(
|
||||
_("Field %s/%s is duplicated.\n" "Please remove the duplications.")
|
||||
|
||||
@@ -85,7 +85,11 @@ class IrModel(models.Model):
|
||||
for field in fields:
|
||||
for table_alias in model_table_map[field.model_id.id]:
|
||||
model_list.append(
|
||||
dict(dict_for_field(field), table_alias=table_alias, join_node=-1,)
|
||||
dict(
|
||||
dict_for_field(field),
|
||||
table_alias=table_alias,
|
||||
join_node=-1,
|
||||
)
|
||||
)
|
||||
return model_list
|
||||
|
||||
@@ -125,16 +129,15 @@ class IrModel(models.Model):
|
||||
|
||||
@api.model
|
||||
def get_related_models(self, model_table_map):
|
||||
""" Return list of model dicts for all models that can be
|
||||
joined with the already selected models.
|
||||
"""Return list of model dicts for all models that can be
|
||||
joined with the already selected models.
|
||||
"""
|
||||
domain = self._get_related_models_domain(model_table_map)
|
||||
return self.sudo().search(domain, order="name asc")
|
||||
|
||||
@api.model
|
||||
def get_models(self, table_model_map=None):
|
||||
""" Return list of model dicts for all available models.
|
||||
"""
|
||||
"""Return list of model dicts for all available models."""
|
||||
self = self.with_context(lang=self.env.user.lang)
|
||||
model_table_map = defaultdict(list)
|
||||
for k, v in (table_model_map or {}).items():
|
||||
@@ -150,10 +153,10 @@ class IrModel(models.Model):
|
||||
|
||||
@api.model
|
||||
def get_join_nodes(self, field_data, new_field):
|
||||
""" Return list of field dicts of join nodes
|
||||
"""Return list of field dicts of join nodes
|
||||
|
||||
Return all possible join nodes to add new_field to the query
|
||||
containing model_ids.
|
||||
Return all possible join nodes to add new_field to the query
|
||||
containing model_ids.
|
||||
"""
|
||||
|
||||
def remove_duplicate_nodes(join_nodes):
|
||||
|
||||
Reference in New Issue
Block a user