odoo/doc/howtos/backend/exercise-constraint-sql

25 lines
750 B
Plaintext

# HG changeset patch
# Parent 121bbfe120be3007f5e04611dbc27038abafcce8
Index: addons/openacademy/models.py
===================================================================
--- addons.orig/openacademy/models.py 2014-08-26 17:26:07.479783261 +0200
+++ addons/openacademy/models.py 2014-08-26 17:26:07.475783261 +0200
@@ -14,6 +14,16 @@
'openacademy.session', 'course_id', string="Session")
+ _sql_constraints = [
+ ('name_description_check',
+ 'CHECK(name != description)',
+ "The title of the course should not be the description"),
+
+ ('name_unique',
+ 'UNIQUE(name)',
+ "The course title must be unique"),
+ ]
+
class Session(models.Model):
_name = 'openacademy.session'