From c2d2b0481efd7d03e1bd4195482230cf87cce663 Mon Sep 17 00:00:00 2001 From: Fabien Bourgeois Date: Sun, 9 Oct 2016 11:01:09 +0200 Subject: [PATCH] [IMP]GOLEM Activity Session Registration handling of cancelations --- .../models/golem_activity_session_registration.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 339f165..f79c694 100644 --- a/golem_activity_session_registration/models/golem_activity_session_registration.py +++ b/golem_activity_session_registration/models/golem_activity_session_registration.py @@ -44,6 +44,21 @@ class GolemMember(models.Model): lambda r: r.state == 'draft') draft_registrations.write({'state': 'confirmed'}) + @api.multi + def write(self, values): + # Handle removed activities to be canceled + if 'activity_session_registration_ids' in values: + rids = values['activity_session_registration_ids'] + r_keep, r_removed = [], [] + for r in rids: # == 2 is removal case + r_removed.append(r) if r[0] == 2 else r_keep.append(r) + rObj = self.env['golem.activity.session.registration'] + for r in r_removed: + r = rObj.browse([r[1]]) + r.state = 'canceled' + values['activity_session_registration_ids'] = r_keep + return super(GolemMember, self).write(values) + class GolemActivitySession(models.Model): _inherit = 'golem.activity.session'