[ADD] doc: new documentation, with training tutorials, and new scaffolding
[odoo/odoo.git] / doc / howtos / backend / exercise-onchange
1 # HG changeset patch
2 # Parent 8d5573b704b2867788dd6895503f1871c2976a29
3
4 Index: doc-backend/openacademy/course.py
5 ===================================================================
6 --- doc-backend.orig/openacademy/course.py      2014-08-22 17:01:50.147102793 +0200
7 +++ doc-backend/openacademy/course.py   2014-08-22 17:01:50.139102793 +0200
8 @@ -39,3 +39,20 @@
9          else:
10              self.taken_seats = 100.0 * len(self.attendee_ids) / self.seats
11  
12 +    @api.onchange('seats', 'attendee_ids')
13 +    def _verify_valid_seats(self):
14 +        if self.seats < 0:
15 +            return {
16 +                'warning': {
17 +                    'title': "Incorrect 'seats' value",
18 +                    'message': "The number of available seats may not be negative",
19 +                },
20 +            }
21 +        if self.seats < len(self.attendee_ids):
22 +            return {
23 +                'warning': {
24 +                    'title': "Too many attendees",
25 +                    'message': "Increase seats or remove excess attendees",
26 +                },
27 +            }
28 +