From f2ee1e99ac8b87fc4526278fef686750cfcc2a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Tue, 11 Jun 2019 11:50:17 +0200 Subject: [PATCH] [IMP] b_emc: Info session confirmation in new coop form This lets user configure if the info session confirmation should be shown and/or required in the new cooperator form. --- beesdoo_easy_my_coop/__init__.py | 1 + beesdoo_easy_my_coop/__openerp__.py | 3 +- beesdoo_easy_my_coop/controllers/__init__.py | 2 ++ beesdoo_easy_my_coop/controllers/main.py | 19 ++++++++++++ beesdoo_easy_my_coop/models/__init__.py | 1 + beesdoo_easy_my_coop/models/res_company.py | 27 +++++++++++++++++ .../models/subscription_request.py | 7 +++++ beesdoo_easy_my_coop/views/res_company.xml | 20 +++++++++++++ .../views/subscription_templates.xml | 29 ++++++++----------- 9 files changed, 91 insertions(+), 18 deletions(-) create mode 100644 beesdoo_easy_my_coop/controllers/__init__.py create mode 100644 beesdoo_easy_my_coop/controllers/main.py create mode 100644 beesdoo_easy_my_coop/models/res_company.py create mode 100644 beesdoo_easy_my_coop/views/res_company.xml diff --git a/beesdoo_easy_my_coop/__init__.py b/beesdoo_easy_my_coop/__init__.py index 164f90c..c311c55 100644 --- a/beesdoo_easy_my_coop/__init__.py +++ b/beesdoo_easy_my_coop/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- import models from . import wizards +from . import controllers diff --git a/beesdoo_easy_my_coop/__openerp__.py b/beesdoo_easy_my_coop/__openerp__.py index 8c1e40d..94e4f50 100644 --- a/beesdoo_easy_my_coop/__openerp__.py +++ b/beesdoo_easy_my_coop/__openerp__.py @@ -16,7 +16,7 @@ # Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml # for the full list 'category': 'Cooperative management', - 'version': '1.0', + 'version': '9.0.1.1.0', # any module necessary for this one to work correctly 'depends': ['beesdoo_base', 'beesdoo_shift', 'easy_my_coop', 'easy_my_coop_eater'], @@ -25,6 +25,7 @@ 'data': [ 'data/product_share.xml', 'views/partner.xml', + 'views/res_company.xml', 'views/subscription_request.xml', 'views/subscription_templates.xml', ], diff --git a/beesdoo_easy_my_coop/controllers/__init__.py b/beesdoo_easy_my_coop/controllers/__init__.py new file mode 100644 index 0000000..757b12a --- /dev/null +++ b/beesdoo_easy_my_coop/controllers/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import main diff --git a/beesdoo_easy_my_coop/controllers/main.py b/beesdoo_easy_my_coop/controllers/main.py new file mode 100644 index 0000000..3e8a587 --- /dev/null +++ b/beesdoo_easy_my_coop/controllers/main.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from openerp import http +from openerp.http import request + +from openerp.addons.easy_my_coop.controllers.main import WebsiteSubscription as Base + +class WebsiteSubscription(Base): + + @http.route() + def display_become_cooperator_page(self, **kwargs): + response = (super(WebsiteSubscription, self) + .display_become_cooperator_page(**kwargs)) + cmp = request.env['res.company']._company_default_get() + response.qcontext.update({ + 'display_info_session': cmp.display_info_session_confirmation, + 'info_session_required': cmp.info_session_confirmation_required, + 'info_session_text': cmp.info_session_confirmation_text, + }) + return response diff --git a/beesdoo_easy_my_coop/models/__init__.py b/beesdoo_easy_my_coop/models/__init__.py index 07eb334..def4978 100644 --- a/beesdoo_easy_my_coop/models/__init__.py +++ b/beesdoo_easy_my_coop/models/__init__.py @@ -1,2 +1,3 @@ import res_partner from . import subscription_request +from . import res_company diff --git a/beesdoo_easy_my_coop/models/res_company.py b/beesdoo_easy_my_coop/models/res_company.py new file mode 100644 index 0000000..bd1f360 --- /dev/null +++ b/beesdoo_easy_my_coop/models/res_company.py @@ -0,0 +1,27 @@ +# -*- 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 ResCompany(models.Model): + + _inherit = 'res.company' + display_info_session_confirmation = fields.Boolean( + help="Choose to display a info session checkbox on the cooperator" + " website form." + ) + info_session_confirmation_required = fields.Boolean( + string="Is info session confirmation required?" + ) + info_session_confirmation_text = fields.Html( + translate=True, + help="Text to display aside the checkbox to confirm" + " participation to an info session." + ) + + @api.onchange('info_session_confirmation_required') + def onchange_info_session_confirmatio_required(self): + if self.info_session_confirmation_required: + self.display_info_session_confirmation = True diff --git a/beesdoo_easy_my_coop/models/subscription_request.py b/beesdoo_easy_my_coop/models/subscription_request.py index e59316b..77e8b5d 100644 --- a/beesdoo_easy_my_coop/models/subscription_request.py +++ b/beesdoo_easy_my_coop/models/subscription_request.py @@ -18,3 +18,10 @@ class SubscriptionRequest(models.Model): partner_vals = super(SubscriptionRequest, self).get_partner_vals() partner_vals['info_session_confirmed'] = self.info_session_confirmed return partner_vals + + def get_required_field(self): + required_fields = super(SubscriptionRequest, self).get_required_fiels() + company = self.env['res.company']._company_default_get() + if company.info_session_confirmation_required: + required_fields.append('info_session_confirmed') + return required_fields diff --git a/beesdoo_easy_my_coop/views/res_company.xml b/beesdoo_easy_my_coop/views/res_company.xml new file mode 100644 index 0000000..daa8557 --- /dev/null +++ b/beesdoo_easy_my_coop/views/res_company.xml @@ -0,0 +1,20 @@ + + + + + + + res.company.form (in beesdoo_easy_my_coop) + res.company + + + + + + + + + + + diff --git a/beesdoo_easy_my_coop/views/subscription_templates.xml b/beesdoo_easy_my_coop/views/subscription_templates.xml index 6292abf..264204a 100644 --- a/beesdoo_easy_my_coop/views/subscription_templates.xml +++ b/beesdoo_easy_my_coop/views/subscription_templates.xml @@ -7,27 +7,22 @@ - - - -