769eafb483
Flectra is Forked from Odoo v11 commit : (6135e82d73
)
29 lines
1017 B
Plaintext
29 lines
1017 B
Plaintext
# HG changeset patch
|
|
# Parent 8d5573b704b2867788dd6895503f1871c2976a29
|
|
# Parent 9eb163e5da677a0d09e01a354ba56697b576a4bc
|
|
|
|
diff --git a/openacademy/models.py b/openacademy/models.py
|
|
--- a/openacademy/models.py
|
|
+++ b/openacademy/models.py
|
|
@@ -39,3 +39,20 @@ class Session(models.Model):
|
|
r.taken_seats = 0.0
|
|
else:
|
|
r.taken_seats = 100.0 * len(r.attendee_ids) / r.seats
|
|
+
|
|
+ @api.onchange('seats', 'attendee_ids')
|
|
+ def _verify_valid_seats(self):
|
|
+ if self.seats < 0:
|
|
+ return {
|
|
+ 'warning': {
|
|
+ 'title': "Incorrect 'seats' value",
|
|
+ 'message': "The number of available seats may not be negative",
|
|
+ },
|
|
+ }
|
|
+ if self.seats < len(self.attendee_ids):
|
|
+ return {
|
|
+ 'warning': {
|
|
+ 'title': "Too many attendees",
|
|
+ 'message': "Increase seats or remove excess attendees",
|
|
+ },
|
|
+ }
|