From ee90b7e551e52a64867e98e99e8e053fedfd5afe Mon Sep 17 00:00:00 2001 From: Patrick Hoste Date: Fri, 19 Nov 2021 09:51:19 +0000 Subject: [PATCH] [ADD] website_mass_mailing_sms: new module adding template to newsletter snippet PURPOSE This commit adds a new bridge module that allows one to select the SMS Template for the newsletter block snippets that allows the user to enter his mobile phone and get the latest news via mobile text. LINKS Task-2672194 Part-of: odoo/odoo#79582 --- addons/website_mass_mailing_sms/__init__.py | 4 +++ .../website_mass_mailing_sms/__manifest__.py | 20 +++++++++++++ .../controllers/__init__.py | 4 +++ .../controllers/main.py | 23 +++++++++++++++ .../data/ir_model_data.xml | 11 +++++++ .../views/snippets/snippets_templates.xml | 29 +++++++++++++++++++ 6 files changed, 91 insertions(+) create mode 100644 addons/website_mass_mailing_sms/__init__.py create mode 100644 addons/website_mass_mailing_sms/__manifest__.py create mode 100644 addons/website_mass_mailing_sms/controllers/__init__.py create mode 100644 addons/website_mass_mailing_sms/controllers/main.py create mode 100644 addons/website_mass_mailing_sms/data/ir_model_data.xml create mode 100644 addons/website_mass_mailing_sms/views/snippets/snippets_templates.xml diff --git a/addons/website_mass_mailing_sms/__init__.py b/addons/website_mass_mailing_sms/__init__.py new file mode 100644 index 00000000000..dd15b5c32e5 --- /dev/null +++ b/addons/website_mass_mailing_sms/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import controllers diff --git a/addons/website_mass_mailing_sms/__manifest__.py b/addons/website_mass_mailing_sms/__manifest__.py new file mode 100644 index 00000000000..c967db7edd8 --- /dev/null +++ b/addons/website_mass_mailing_sms/__manifest__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +{ + 'name': 'Newsletter Subscribe SMS Template', + 'summary': 'Attract visitors to subscribe to mailing lists', + 'description': """ +This module adds a new template to the Newsletter Block to allow +your visitors to subscribe with their phone number. + """, + 'version': '1.0', + 'category': 'Website/Website', + 'depends': ['website_mass_mailing', 'mass_mailing_sms'], + 'data': [ + 'views/snippets/snippets_templates.xml', + 'data/ir_model_data.xml', + ], + 'auto_install': True, + 'license': 'LGPL-3', +} diff --git a/addons/website_mass_mailing_sms/controllers/__init__.py b/addons/website_mass_mailing_sms/controllers/__init__.py new file mode 100644 index 00000000000..5d4b25db9c0 --- /dev/null +++ b/addons/website_mass_mailing_sms/controllers/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import main diff --git a/addons/website_mass_mailing_sms/controllers/main.py b/addons/website_mass_mailing_sms/controllers/main.py new file mode 100644 index 00000000000..8384aa31323 --- /dev/null +++ b/addons/website_mass_mailing_sms/controllers/main.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.http import request +from odoo.addons.mass_mailing.controllers import main + + +class MassMailController(main.MassMailController): + + def _get_value(self, subscription_type): + value = super(MassMailController, self)._get_value(subscription_type) + if not value and subscription_type == 'mobile': + if not request.env.user._is_public(): + value = request.env.user.partner_id.mobile + elif request.session.get('mass_mailing_mobile'): + value = request.session['mass_mailing_mobile'] + return value + + def _get_fname(self, subscription_type): + value_field = super(MassMailController, self)._get_fname(subscription_type) + if not value_field and subscription_type == 'mobile': + value_field = 'mobile' + return value_field diff --git a/addons/website_mass_mailing_sms/data/ir_model_data.xml b/addons/website_mass_mailing_sms/data/ir_model_data.xml new file mode 100644 index 00000000000..3209cabe768 --- /dev/null +++ b/addons/website_mass_mailing_sms/data/ir_model_data.xml @@ -0,0 +1,11 @@ + + + + + mailing.contact + + + + diff --git a/addons/website_mass_mailing_sms/views/snippets/snippets_templates.xml b/addons/website_mass_mailing_sms/views/snippets/snippets_templates.xml new file mode 100644 index 00000000000..f9ccb8b86d9 --- /dev/null +++ b/addons/website_mass_mailing_sms/views/snippets/snippets_templates.xml @@ -0,0 +1,29 @@ + + + + + + + +