diff options
| author | Christophe Simonis <chs@odoo.com> | 2014-09-05 15:28:22 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2014-09-05 15:28:22 +0200 |
| commit | 31bf30d2d0eb78baaa36360b99fe58bf7cd4c9e7 (patch) | |
| tree | d7be61ecd6bb4c8b5552e39b03e2a64eebbbf323 /doc/howtos/backend/exercise-constraint-python | |
| parent | afba9e8817c458640ae446ac7aaaab79be4fe1e9 (diff) | |
| parent | ed1c173971968eaa96693cb4e1547efa6e6c34e0 (diff) | |
[MERGE] forward port of branch 8.0 up to ed1c173
Diffstat (limited to 'doc/howtos/backend/exercise-constraint-python')
| -rw-r--r-- | doc/howtos/backend/exercise-constraint-python | 25 |
1 files changed, 25 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..9818fe8d395 --- /dev/null +++ b/doc/howtos/backend/exercise-constraint-python @@ -0,0 +1,25 @@ +# HG changeset patch +# Parent 7a7d003fe38426a405ce0657a627a139133ec4dd + +Index: addons/openacademy/models.py +=================================================================== +--- addons.orig/openacademy/models.py 2014-08-26 17:26:06.591783274 +0200 ++++ addons/openacademy/models.py 2014-08-26 17:26:06.587783274 +0200 +@@ -1,6 +1,6 @@ + # -*- coding: utf-8 -*- + +-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") |
