flectra/doc/howtos/backend/exercise-constraint-sql
flectra-admin 769eafb483 [INIT] Inception of Flectra from Odoo
Flectra is Forked from Odoo v11 commit : (6135e82d73)
2018-01-16 11:45:59 +05:30

25 lines
785 B
Plaintext

# HG changeset patch
# Parent 121bbfe120be3007f5e04611dbc27038abafcce8
Index: addons/openacademy/models.py
===================================================================
--- addons.orig/openacademy/models.py 2014-08-27 14:19:33.099111181 +0200
+++ addons/openacademy/models.py 2014-08-27 14:20:03.311110732 +0200
@@ -13,6 +13,16 @@
session_ids = fields.One2many(
'openacademy.session', 'course_id', string="Sessions")
+ _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'