From 5620949ca041a332d685aa7e377f0135b98e4922 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Tue, 1 Sep 2015 09:14:58 +0200 Subject: [PATCH] Add unique constraint on the view's name in PG --- sql_view/models/sql_view.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sql_view/models/sql_view.py b/sql_view/models/sql_view.py index c77fd57d7..23df3cf09 100644 --- a/sql_view/models/sql_view.py +++ b/sql_view/models/sql_view.py @@ -103,6 +103,11 @@ class SQLView(orm.Model): ['definition']), ] + _sql_constraints = [ + ('sql_name_uniq', 'unique (sql_name)', + 'Another view has the same SQL name.') + ] + def _sql_view_comment(self, cr, uid, sql_view, context=None): return "%s (created by the module sql_view)" % sql_view.name