bi_view_editor: Better error message if the query is not correct

This commit is contained in:
SimoRubi
2020-05-07 14:39:04 +02:00
committed by Andrea
parent c76552c224
commit 2d17441547
3 changed files with 32 additions and 3 deletions

View File

@@ -295,8 +295,16 @@ class BveView(models.Model):
self._cr.execute('DROP TABLE IF EXISTS %s', (AsIs(view_name), ))
# create postgres view
self.env.cr.execute('CREATE or REPLACE VIEW %s as (%s)', (
AsIs(view_name), AsIs(query), ))
try:
with self.env.cr.savepoint():
self.env.cr.execute('CREATE or REPLACE VIEW %s as (%s)', (
AsIs(view_name), AsIs(query), ))
except Exception as e:
raise UserError(
_("Error creating the view '{query}':\n{error}")
.format(
query=query,
error=e))
@api.depends('line_ids', 'state', 'over_condition')
def _compute_sql_query(self):