Skip to content

Commit

Permalink
IMP: bi_sql_editor raise UserError when matching on field is not found
Browse files Browse the repository at this point in the history
When creating a new SQL view, if the naming is not met you end with
that have an invalid definition.
 => the model is not found.

This will lead to errors when trying to load the tree view

The goal here is to raise an error and warn the user about it.
  • Loading branch information
leemannd committed Nov 14, 2023
1 parent efa05ba commit e8b4005
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bi_sql_editor/models/bi_sql_view_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ def create(self, vals):
many2one_model_id = (
self.env["ir.model"].search([("model", "=", model_name)]).id
)
if not many2one_model_id:
raise UserError(_("There is no relation matching for the field %s", field_without_prefix))

Check warning on line 172 in bi_sql_editor/models/bi_sql_view_field.py

View check run for this annotation

Codecov / codecov/patch

bi_sql_editor/models/bi_sql_view_field.py#L172

Added line #L172 was not covered by tests

vals.update(
{
Expand Down

0 comments on commit e8b4005

Please sign in to comment.