[IMP] bi_sql_editor manual field check performance

The `table_columns()` slows down modules loading significantly up to 2-3x.
In most cases `model._name.startswith(self._model_prefix)` returns `False`, so better to check it first.
This commit is contained in:
Paulius Sladkevičius
2022-11-16 12:45:40 +01:00
committed by thien
parent a102a7f115
commit 3c1b094582
2 changed files with 4 additions and 4 deletions

View File

@@ -704,9 +704,9 @@ class BiSQLView(models.Model):
def check_manual_fields(self, model):
# check the fields we need are defined on self, to stop it going
# early on install / startup - particularly problematic during upgrade
if "group_operator" in table_columns(
self.env.cr, "bi_sql_view_field"
) and model._name.startswith(self._model_prefix):
if model._name.startswith(
self._model_prefix
) and "group_operator" in table_columns(self.env.cr, "bi_sql_view_field"):
# Use SQL instead of ORM, as ORM might not be fully initialised -
# we have no control over the order that fields are defined!
# We are not concerned about user security rules.

View File

@@ -180,7 +180,7 @@ class BiSQLViewField(models.Model):
"many2one_model_id": many2one_model_id,
}
)
return super().create(vals)
return super().create(vals_list)
# Custom Section
@api.model