From 27212ed664dec750a31f3e97d4c5a98a2c4aa367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Fri, 31 May 2019 12:03:47 +0200 Subject: [PATCH] [ADD] b_easy_my_coop: Info Session in new cooperator form This adds, in the new cooperator form in the website, a checkbox that the user can check if he already has taken part to an information session. This information will be saved in the partner object and will be used to automatically check the info_session field of the cooperator_status when it will be created by the wizard. --- beesdoo_easy_my_coop/__init__.py | 3 +- beesdoo_easy_my_coop/__openerp__.py | 2 ++ beesdoo_easy_my_coop/models/__init__.py | 3 +- beesdoo_easy_my_coop/models/res_partner.py | 4 +++ .../models/subscription_request.py | 20 +++++++++++ .../views/subscription_request.xml | 18 ++++++++++ .../views/subscription_templates.xml | 34 +++++++++++++++++++ beesdoo_easy_my_coop/wizards/__init__.py | 1 + .../wizards/beesdoo_shift_subscribe.py | 25 ++++++++++++++ 9 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 beesdoo_easy_my_coop/models/subscription_request.py create mode 100644 beesdoo_easy_my_coop/views/subscription_request.xml create mode 100644 beesdoo_easy_my_coop/views/subscription_templates.xml create mode 100644 beesdoo_easy_my_coop/wizards/__init__.py create mode 100644 beesdoo_easy_my_coop/wizards/beesdoo_shift_subscribe.py diff --git a/beesdoo_easy_my_coop/__init__.py b/beesdoo_easy_my_coop/__init__.py index 0f7cb6b..164f90c 100644 --- a/beesdoo_easy_my_coop/__init__.py +++ b/beesdoo_easy_my_coop/__init__.py @@ -1,2 +1,3 @@ # -*- coding: utf-8 -*- -import models \ No newline at end of file +import models +from . import wizards diff --git a/beesdoo_easy_my_coop/__openerp__.py b/beesdoo_easy_my_coop/__openerp__.py index cae610c..8c1e40d 100644 --- a/beesdoo_easy_my_coop/__openerp__.py +++ b/beesdoo_easy_my_coop/__openerp__.py @@ -25,6 +25,8 @@ 'data': [ 'data/product_share.xml', 'views/partner.xml', + 'views/subscription_request.xml', + 'views/subscription_templates.xml', ], 'auto_install': True, # only loaded in demonstration mode diff --git a/beesdoo_easy_my_coop/models/__init__.py b/beesdoo_easy_my_coop/models/__init__.py index f6dfb12..07eb334 100644 --- a/beesdoo_easy_my_coop/models/__init__.py +++ b/beesdoo_easy_my_coop/models/__init__.py @@ -1 +1,2 @@ -import res_partner \ No newline at end of file +import res_partner +from . import subscription_request diff --git a/beesdoo_easy_my_coop/models/res_partner.py b/beesdoo_easy_my_coop/models/res_partner.py index 1bde775..21f13ac 100644 --- a/beesdoo_easy_my_coop/models/res_partner.py +++ b/beesdoo_easy_my_coop/models/res_partner.py @@ -6,6 +6,10 @@ class Partner(models.Model): cooperator_type = fields.Selection(selection='_get_share_type', compute='_compute_share_type', string='Cooperator Type', store=True) can_shop = fields.Boolean(compute='_can_shop', store=True) + info_session_confirmed = fields.Boolean( + string="Confirmed presence to info session", + default=False, + ) @api.depends('cooperator_type', 'cooperative_status_ids', 'cooperative_status_ids.can_shop') def _can_shop(self): diff --git a/beesdoo_easy_my_coop/models/subscription_request.py b/beesdoo_easy_my_coop/models/subscription_request.py new file mode 100644 index 0000000..e59316b --- /dev/null +++ b/beesdoo_easy_my_coop/models/subscription_request.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Coop IT Easy SCRLfs +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import api, fields, models, _ + + +class SubscriptionRequest(models.Model): + + _inherit = 'subscription.request' + + info_session_confirmed = fields.Boolean( + string="Confirmed Info Session", + default=False, + ) + + def get_partner_vals(self): + partner_vals = super(SubscriptionRequest, self).get_partner_vals() + partner_vals['info_session_confirmed'] = self.info_session_confirmed + return partner_vals diff --git a/beesdoo_easy_my_coop/views/subscription_request.xml b/beesdoo_easy_my_coop/views/subscription_request.xml new file mode 100644 index 0000000..1b75719 --- /dev/null +++ b/beesdoo_easy_my_coop/views/subscription_request.xml @@ -0,0 +1,18 @@ + + + + + + + subscription.request.form (in beesdoo_easy_my_coop) + subscription.request + + + + + + + + + diff --git a/beesdoo_easy_my_coop/views/subscription_templates.xml b/beesdoo_easy_my_coop/views/subscription_templates.xml new file mode 100644 index 0000000..b480c8d --- /dev/null +++ b/beesdoo_easy_my_coop/views/subscription_templates.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + diff --git a/beesdoo_easy_my_coop/wizards/__init__.py b/beesdoo_easy_my_coop/wizards/__init__.py new file mode 100644 index 0000000..eb54c76 --- /dev/null +++ b/beesdoo_easy_my_coop/wizards/__init__.py @@ -0,0 +1 @@ +from . import beesdoo_shift_subscribe diff --git a/beesdoo_easy_my_coop/wizards/beesdoo_shift_subscribe.py b/beesdoo_easy_my_coop/wizards/beesdoo_shift_subscribe.py new file mode 100644 index 0000000..a411179 --- /dev/null +++ b/beesdoo_easy_my_coop/wizards/beesdoo_shift_subscribe.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Copyright 2019 Coop IT Easy SCRLfs +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import api, fields, models, _ + + +class Subscribe(models.TransientModel): + + _inherit = 'beesdoo.shift.subscribe' + + def _get_info_session_followed(self): + """ + Check if the user has checked the info_session_confirmed in the + form to become new cooperator. + """ + followed = super(Subscribe, self)._get_info_session_followed() + if not followed: + return (self.env['res.partner'] + .browse(self._context.get('active_id')) + .info_session_confirmed) + return followed + + info_session = fields.Boolean(default=_get_info_session_followed) +