dad20c592c72961702e0258663e8dd45c727a60f
[odoo/odoo.git] / doc / howtos / backend / exercise-constraint-sql
1 # HG changeset patch
2 # Parent 121bbfe120be3007f5e04611dbc27038abafcce8
3
4 Index: addons/openacademy/models.py
5 ===================================================================
6 --- addons.orig/openacademy/models.py   2014-08-26 17:26:07.479783261 +0200
7 +++ addons/openacademy/models.py        2014-08-26 17:26:07.475783261 +0200
8 @@ -14,6 +14,16 @@
9          'openacademy.session', 'course_id', string="Session")
10  
11  
12 +    _sql_constraints = [
13 +        ('name_description_check',
14 +         'CHECK(name != description)',
15 +         "The title of the course should not be the description"),
16 +
17 +        ('name_unique',
18 +         'UNIQUE(name)',
19 +         "The course title must be unique"),
20 +    ]
21 +
22  class Session(models.Model):
23      _name = 'openacademy.session'
24