[ADD] doc: new documentation, with training tutorials, and new scaffolding
[odoo/odoo.git] / doc / howtos / backend / exercise-constraint-python
1 # HG changeset patch
2 # Parent 7a7d003fe38426a405ce0657a627a139133ec4dd
3
4 Index: doc-backend/openacademy/course.py
5 ===================================================================
6 --- doc-backend.orig/openacademy/course.py      2014-08-22 17:02:00.987103191 +0200
7 +++ doc-backend/openacademy/course.py   2014-08-22 17:02:00.983103191 +0200
8 @@ -1,5 +1,5 @@
9  # -*- coding: utf-8 -*-
10 -from openerp import api, fields, models
11 +from openerp import api, fields, models, exceptions
12  
13  class Course(models.Model):
14      _name = 'openacademy.course'
15 @@ -56,3 +56,9 @@
16                  },
17              }
18  
19 +    @api.one
20 +    @api.constrains('instructor_id', 'attendee_ids')
21 +    def _check_instructor_not_in_attendees(self):
22 +        if self.instructor_id and self.instructor_id in self.attendee_ids:
23 +            raise exceptions.ValidationError("A session's instructor can't be an attendee")
24 +