summaryrefslogtreecommitdiff
path: root/doc/howtos/backend/exercise-constraint-python
diff options
context:
space:
mode:
authorRaphael Collet <rco@openerp.com>2014-08-22 17:51:20 +0200
committerRaphael Collet <rco@openerp.com>2014-08-22 17:51:20 +0200
commit2ad092b5e54fa39a906b38d9240e08b9800ea0da (patch)
tree1879c2a6efe8ed1626d92635870aaff922306492 /doc/howtos/backend/exercise-constraint-python
parent97256fa1fba6c7d3d02962b5948158d17852cf43 (diff)
[ADD] doc: new documentation, with training tutorials, and new scaffolding
Diffstat (limited to 'doc/howtos/backend/exercise-constraint-python')
-rw-r--r--doc/howtos/backend/exercise-constraint-python24
1 files changed, 24 insertions, 0 deletions
diff --git a/doc/howtos/backend/exercise-constraint-python b/doc/howtos/backend/exercise-constraint-python
new file mode 100644
index 00000000000..c2f0b8a6114
--- /dev/null
+++ b/doc/howtos/backend/exercise-constraint-python
@@ -0,0 +1,24 @@
+# HG changeset patch
+# Parent 7a7d003fe38426a405ce0657a627a139133ec4dd
+
+Index: doc-backend/openacademy/course.py
+===================================================================
+--- doc-backend.orig/openacademy/course.py 2014-08-22 17:02:00.987103191 +0200
++++ doc-backend/openacademy/course.py 2014-08-22 17:02:00.983103191 +0200
+@@ -1,5 +1,5 @@
+ # -*- coding: utf-8 -*-
+-from openerp import api, fields, models
++from openerp import api, fields, models, exceptions
+
+ class Course(models.Model):
+ _name = 'openacademy.course'
+@@ -56,3 +56,9 @@
+ },
+ }
+
++ @api.one
++ @api.constrains('instructor_id', 'attendee_ids')
++ def _check_instructor_not_in_attendees(self):
++ if self.instructor_id and self.instructor_id in self.attendee_ids:
++ raise exceptions.ValidationError("A session's instructor can't be an attendee")
++