From ebe3c9bde5f97108a954c786b68053f1fdaf9dc8 Mon Sep 17 00:00:00 2001 From: Fabien Bourgeois Date: Thu, 22 Sep 2016 17:15:14 +0200 Subject: [PATCH] [IMP]GOLEM Activity Session Registration state validation from draft to confirmed --- .../golem_activity_session_registration.py | 20 +++++++++++++++++++ ...lem_activity_session_registration_view.xml | 2 +- .../views/golem_activity_view.xml | 2 +- .../views/golem_member_view.xml | 12 ++++++++++- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/golem_activity_session_registration/models/golem_activity_session_registration.py b/golem_activity_session_registration/models/golem_activity_session_registration.py index 6c6aaeb..339f165 100644 --- a/golem_activity_session_registration/models/golem_activity_session_registration.py +++ b/golem_activity_session_registration/models/golem_activity_session_registration.py @@ -23,6 +23,26 @@ class GolemMember(models.Model): activity_session_registration_ids = fields.One2many( 'golem.activity.session.registration', 'member_id', 'Activities') + has_draft_registrations = fields.Boolean( + 'Has draft registrations ?', + compute='_compute_has_draft_registrations') + + @api.one + @api.depends('activity_session_registration_ids') + def _compute_has_draft_registrations(self): + """ Check if there are draft states in member activities """ + for r in self.activity_session_registration_ids: + if r.state == 'draft': + self.has_draft_registrations = True + return + self.has_draft_registrations = False + + @api.one + def do_validate_registrations(self): + """ Validate all draft registrations """ + draft_registrations = self.activity_session_registration_ids.filtered( + lambda r: r.state == 'draft') + draft_registrations.write({'state': 'confirmed'}) class GolemActivitySession(models.Model): diff --git a/golem_activity_session_registration/views/golem_activity_session_registration_view.xml b/golem_activity_session_registration/views/golem_activity_session_registration_view.xml index e0e6e5b..e28293e 100644 --- a/golem_activity_session_registration/views/golem_activity_session_registration_view.xml +++ b/golem_activity_session_registration/views/golem_activity_session_registration_view.xml @@ -41,7 +41,7 @@ along with this program. If not, see . golem.activity.session.registration + colors="red: state == 'canceled';darkgrey: state == 'draft';"> diff --git a/golem_activity_session_registration/views/golem_activity_view.xml b/golem_activity_session_registration/views/golem_activity_view.xml index a2d6a24..5c28578 100644 --- a/golem_activity_session_registration/views/golem_activity_view.xml +++ b/golem_activity_session_registration/views/golem_activity_view.xml @@ -34,7 +34,7 @@ along with this program. If not, see . + colors="red: state == 'canceled';darkgrey: state == 'draft';"> diff --git a/golem_activity_session_registration/views/golem_member_view.xml b/golem_activity_session_registration/views/golem_member_view.xml index cbe2691..9a441c7 100644 --- a/golem_activity_session_registration/views/golem_member_view.xml +++ b/golem_activity_session_registration/views/golem_member_view.xml @@ -27,10 +27,20 @@ along with this program. If not, see .

Default season activities

+

+ +