[IMP] doc/howtos/backend: use scaffolding and adapt text and code accordingly
[odoo/odoo.git] / doc / howtos / backend / exercise-constraint-python
index c2f0b8a..a3a18d4 100644 (file)
@@ -1,24 +1,25 @@
 # HG changeset patch
 # Parent 7a7d003fe38426a405ce0657a627a139133ec4dd
 
-Index: doc-backend/openacademy/course.py
+Index: doc-backend/openacademy/models.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 @@
+--- doc-backend.orig/openacademy/models.py     2014-08-24 12:16:56.413385666 +0200
++++ doc-backend/openacademy/models.py  2014-08-24 12:17:11.137386006 +0200
+@@ -1,6 +1,6 @@
  # -*- coding: utf-8 -*-
--from openerp import api, fields, models
-+from openerp import api, fields, models, exceptions
+-from openerp import models, fields, api
++from openerp import models, fields, api, exceptions
  
  class Course(models.Model):
      _name = 'openacademy.course'
 @@ -56,3 +56,9 @@
+                     'message': "Increase seats or remove excess attendees",
                  },
              }
++
 +    @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")
-+