diff --git a/mass_mailing_newsletter_welcome_mail/README.rst b/mass_mailing_newsletter_welcome_mail/README.rst index 22987577..8212ec7f 100644 --- a/mass_mailing_newsletter_welcome_mail/README.rst +++ b/mass_mailing_newsletter_welcome_mail/README.rst @@ -1,10 +1,33 @@ -============================================= -Welcome mail for new suscribers on newsletter -============================================= - -This module was written to extend the functionality of the website popup newsletter subscription form -to support sending to new subscribers an automatic welcome email and allow -you to customize it. +=============================== +Welcome mail to new subscribers +=============================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github + :target: https://github.com/OCA/social/tree/11.0/mass_mailing_newsletter_welcome_mail + :alt: OCA/social +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/social-11-0/social-11-0-mass_mailing_newsletter_welcome_mail + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/205/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module was written to extend the functionality of the website popup +newsletter subscription form to support sending to new subscribers an +automatic welcome email and allow you to customize it. **Table of contents** @@ -16,14 +39,42 @@ Configuration To configure this module, you need to: -#. Go to **Settings > Technical > Automation > Automated actions > Welcome mail to newsletter subscribers** and edit anything there. +#. Go to *Email Marketing > Contacts > Mailing Lists*. +#. Edit or create one. +#. Set a *Welcome mail template* to enable this module's special behavior when + somebody subscribes to this mailing list. You can use one shipped with + this module, called *Welcome mail to newsletter subscribers*, + as a starting point. +#. You can also customize this template as you prefer. + +To be used, you also must make sure a subscription snippet for this list exists +somewhere in your website: + +#. Go to your website. +#. Navigate to a page where you want to include the subscription widget. +#. *Edit* the webpage. +#. Drag and drop any *Structure* or *Features* block you like. +#. Drag and drop the *Inner content > Newsletter* block inside it. +#. Choose the same mailing list you configured above. + +Of course, outgoing mail must be properly configured in your instance, or +emails will never be sent. + +Usage +===== + +After you have followed the configuration instructions: -Quicker way to just change the email template (something that most likely you -will want to do): +#. Enter as an anonymous user (you can use a browser private window for that). +#. Navigate to the page where the newsletter subscription snippet is found. +#. Enter your email. +#. Hit *Subscribe*. +#. Check your inbox, you have new mail! -#. Go to **Settings > Technical > Email > Templates** -#. Edit the template called **Welcome mail - Newsletter**. +Known issues / Roadmap +====================== +* Add tests. Bug Tracker =========== @@ -31,7 +82,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -50,6 +101,7 @@ Contributors * `Tecnativa `__: * Cristina Martin R. + * Jairo Llopis Maintainers ~~~~~~~~~~~ @@ -64,6 +116,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/website `_ project on GitHub. +This module is part of the `OCA/social `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mass_mailing_newsletter_welcome_mail/__init__.py b/mass_mailing_newsletter_welcome_mail/__init__.py index e69de29b..91c5580f 100644 --- a/mass_mailing_newsletter_welcome_mail/__init__.py +++ b/mass_mailing_newsletter_welcome_mail/__init__.py @@ -0,0 +1,2 @@ +from . import controllers +from . import models diff --git a/mass_mailing_newsletter_welcome_mail/__manifest__.py b/mass_mailing_newsletter_welcome_mail/__manifest__.py index 04d42342..e97550b6 100644 --- a/mass_mailing_newsletter_welcome_mail/__manifest__.py +++ b/mass_mailing_newsletter_welcome_mail/__manifest__.py @@ -10,11 +10,11 @@ 'version': '11.0.1.0.0', 'website': 'https://github.com/OCA/social', 'depends': [ - 'mass_mailing', - 'base_automation', + 'website_mass_mailing', ], 'data': [ - "data/base_automation_data.xml", + "data/mail_template.xml", + "views/mail_mass_mailing_list.xml", ], 'application': False, 'installable': True, diff --git a/mass_mailing_newsletter_welcome_mail/controllers/__init__.py b/mass_mailing_newsletter_welcome_mail/controllers/__init__.py new file mode 100644 index 00000000..12a7e529 --- /dev/null +++ b/mass_mailing_newsletter_welcome_mail/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/mass_mailing_newsletter_welcome_mail/controllers/main.py b/mass_mailing_newsletter_welcome_mail/controllers/main.py new file mode 100644 index 00000000..32e2119d --- /dev/null +++ b/mass_mailing_newsletter_welcome_mail/controllers/main.py @@ -0,0 +1,31 @@ +# Copyright 2019 Tecnativa - Jairo Llopis +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo.http import request, route +from odoo.addons.website_mass_mailing.controllers import main + + +class MassMailController(main.MassMailController): + @route() + def subscribe(self, list_id, email, **post): + """Send welcome email to subscribers.""" + result = super().subscribe(list_id, email, **post) + list_ = request.env["mail.mass_mailing.list"] \ + .sudo().browse(int(list_id)) + template = list_.welcome_mail_template_id + if not template: + return result + # Welcome new subscribers + contact = request.env["mail.mass_mailing.contact"].sudo().search([ + ('list_ids', 'in', list_.ids), + ('email', '=', email), + ("opt_out", "=", False), + ], limit=1) + template.with_context(list_name=list_.name).send_mail( + contact.id, + # Must send now to use context + force_send=True, + # If we cannot notify, the visitor shouldn't be bothered + raise_exception=False, + ) + return result diff --git a/mass_mailing_newsletter_welcome_mail/data/base_automation_data.xml b/mass_mailing_newsletter_welcome_mail/data/base_automation_data.xml deleted file mode 100644 index 07103f23..00000000 --- a/mass_mailing_newsletter_welcome_mail/data/base_automation_data.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - Welcome mail to newsletter subscribers - - - ${object.env.context.get("lang")} - Welcome to the mailing list ${object.list_id.name} - -
Dear ${object.name}, -
-

Thanks for signing up for our newsletter!

-

Regards,

-
-
-
-
- - - - Send Welcome Mail to new subscribers on Newsletter - - email - on_create - - - - - - -
diff --git a/mass_mailing_newsletter_welcome_mail/data/mail_template.xml b/mass_mailing_newsletter_welcome_mail/data/mail_template.xml new file mode 100644 index 00000000..cdf95ec0 --- /dev/null +++ b/mass_mailing_newsletter_welcome_mail/data/mail_template.xml @@ -0,0 +1,21 @@ + + + + + + Welcome mail to newsletter subscribers + + + ${ctx.get("lang")} + Welcome to the mailing list ${ctx.get("list_name")} + +
Dear ${object.name or object.email}, +
+

Thanks for signing up for our newsletter!

+

Regards,

+
+
+
+ +
diff --git a/mass_mailing_newsletter_welcome_mail/i18n/es.po b/mass_mailing_newsletter_welcome_mail/i18n/es.po new file mode 100644 index 00000000..db2c37ee --- /dev/null +++ b/mass_mailing_newsletter_welcome_mail/i18n/es.po @@ -0,0 +1,40 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mass_mailing_newsletter_welcome_mail +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-05-02 11:06+0000\n" +"PO-Revision-Date: 2019-05-02 12:08+0100\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.2.1\n" +"Last-Translator: Jairo Llopis \n" +"Language: es_ES\n" + +#. module: mass_mailing_newsletter_welcome_mail +#: model:mail.template,body_html:mass_mailing_newsletter_welcome_mail.email_template +msgid "" +"
Dear ${object.name or object.email},\n" +"
\n" +"

Thanks for signing up for our newsletter!

\n" +"

Regards,

\n" +"
\n" +" " +msgstr "" +"
Estimado/a ${object.name or object.email},\n" +"
\n" +"

¡Gracias por suscribirse a nuestro boletín!

\n" +"

Saludos,

\n" +"
\n" +" " + +#. module: mass_mailing_newsletter_welcome_mail +#: model:mail.template,subject:mass_mailing_newsletter_welcome_mail.email_template +msgid "Welcome to the mailing list ${ctx.get(\"list_name\")}" +msgstr "Bienvenido/a a la lista de correo ${ctx.get(\"list_name\")}" diff --git a/mass_mailing_newsletter_welcome_mail/i18n/mass_mailing_welcome_mail.pot b/mass_mailing_newsletter_welcome_mail/i18n/mass_mailing_welcome_mail.pot index c0b01b4c..97da8a56 100644 --- a/mass_mailing_newsletter_welcome_mail/i18n/mass_mailing_welcome_mail.pot +++ b/mass_mailing_newsletter_welcome_mail/i18n/mass_mailing_welcome_mail.pot @@ -1,11 +1,13 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * mass_mailing_welcome_mail +# * mass_mailing_newsletter_welcome_mail # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 12.0\n" +"Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-05-02 11:06+0000\n" +"PO-Revision-Date: 2019-05-02 11:06+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -13,18 +15,17 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" -#. module: mass_mailing_welcome_mail -#: model:mail.template,body_html:mass_mailing_welcome_mail.email_template -msgid "
Dear ${object.name}, -
-

Thanks for signing up for our newsletter!

-

Regards,

-
\n" -" " +#. module: mass_mailing_newsletter_welcome_mail +#: model:mail.template,body_html:mass_mailing_newsletter_welcome_mail.email_template +msgid "
Dear ${object.name or object.email},\n" +"
\n" +"

Thanks for signing up for our newsletter!

\n" +"

Regards,

\n" +"
\n" +" " msgstr "" -#. module: mass_mailing_welcome_mail -#: model:base.automation,name:mass_mailing_welcome_mail.automated_action -#: model:ir.actions.server,name:mass_mailing_welcome_mail.automated_action -msgid "Send Welcome Mail to new subscribers" +#. module: mass_mailing_newsletter_welcome_mail +#: model:mail.template,subject:mass_mailing_newsletter_welcome_mail.email_template +msgid "Welcome to the mailing list ${ctx.get(\"list_name\")}" msgstr "" diff --git a/mass_mailing_newsletter_welcome_mail/models/__init__.py b/mass_mailing_newsletter_welcome_mail/models/__init__.py new file mode 100644 index 00000000..70461d6d --- /dev/null +++ b/mass_mailing_newsletter_welcome_mail/models/__init__.py @@ -0,0 +1 @@ +from . import mail_mass_mailing_list diff --git a/mass_mailing_newsletter_welcome_mail/models/mail_mass_mailing_list.py b/mass_mailing_newsletter_welcome_mail/models/mail_mass_mailing_list.py new file mode 100644 index 00000000..c3c65757 --- /dev/null +++ b/mass_mailing_newsletter_welcome_mail/models/mail_mass_mailing_list.py @@ -0,0 +1,16 @@ +# Copyright 2019 Tecnativa - Jairo Llopis +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class MailMassMailingList(models.Model): + _inherit = 'mail.mass_mailing.list' + + welcome_mail_template_id = fields.Many2one( + string="Welcome mail template", + comodel_name='mail.template', + ondelete='set null', + help="Mail template to be sent when a contact is subscribed from " + "the website." + ) diff --git a/mass_mailing_newsletter_welcome_mail/readme/CONFIGURE.rst b/mass_mailing_newsletter_welcome_mail/readme/CONFIGURE.rst index 134ebe50..58a41b6e 100755 --- a/mass_mailing_newsletter_welcome_mail/readme/CONFIGURE.rst +++ b/mass_mailing_newsletter_welcome_mail/readme/CONFIGURE.rst @@ -1,9 +1,22 @@ To configure this module, you need to: -#. Go to **Settings > Technical > Automation > Automated actions > Welcome mail to New subscribers in Nesletter Mailing List** and edit anything there. +#. Go to *Email Marketing > Contacts > Mailing Lists*. +#. Edit or create one. +#. Set a *Welcome mail template* to enable this module's special behavior when + somebody subscribes to this mailing list. You can use one shipped with + this module, called *Welcome mail to newsletter subscribers*, + as a starting point. +#. You can also customize this template as you prefer. -Quicker way to just change the email template (something that most likely you -will want to do): +To be used, you also must make sure a subscription snippet for this list exists +somewhere in your website: -#. Go to **Settings > Technical > Email > Templates** -#. Edit the template called **Welcome mail - Newsletter Mailing List**. +#. Go to your website. +#. Navigate to a page where you want to include the subscription widget. +#. *Edit* the webpage. +#. Drag and drop any *Structure* or *Features* block you like. +#. Drag and drop the *Inner content > Newsletter* block inside it. +#. Choose the same mailing list you configured above. + +Of course, outgoing mail must be properly configured in your instance, or +emails will never be sent. diff --git a/mass_mailing_newsletter_welcome_mail/readme/CONTRIBUTORS.rst b/mass_mailing_newsletter_welcome_mail/readme/CONTRIBUTORS.rst index e81b810d..9bf68672 100755 --- a/mass_mailing_newsletter_welcome_mail/readme/CONTRIBUTORS.rst +++ b/mass_mailing_newsletter_welcome_mail/readme/CONTRIBUTORS.rst @@ -2,3 +2,4 @@ * `Tecnativa `__: * Cristina Martin R. + * Jairo Llopis diff --git a/mass_mailing_newsletter_welcome_mail/readme/ROADMAP.rst b/mass_mailing_newsletter_welcome_mail/readme/ROADMAP.rst new file mode 100644 index 00000000..c6d3728c --- /dev/null +++ b/mass_mailing_newsletter_welcome_mail/readme/ROADMAP.rst @@ -0,0 +1 @@ +* Add tests. diff --git a/mass_mailing_newsletter_welcome_mail/readme/USAGE.rst b/mass_mailing_newsletter_welcome_mail/readme/USAGE.rst new file mode 100644 index 00000000..db3a3ab1 --- /dev/null +++ b/mass_mailing_newsletter_welcome_mail/readme/USAGE.rst @@ -0,0 +1,7 @@ +After you have followed the configuration instructions: + +#. Enter as an anonymous user (you can use a browser private window for that). +#. Navigate to the page where the newsletter subscription snippet is found. +#. Enter your email. +#. Hit *Subscribe*. +#. Check your inbox, you have new mail! diff --git a/mass_mailing_newsletter_welcome_mail/static/description/index.html b/mass_mailing_newsletter_welcome_mail/static/description/index.html new file mode 100644 index 00000000..67e4f59d --- /dev/null +++ b/mass_mailing_newsletter_welcome_mail/static/description/index.html @@ -0,0 +1,470 @@ + + + + + + +Welcome mail to new subscribers + + + +
+

Welcome mail to new subscribers

+ + +

Beta License: AGPL-3 OCA/social Translate me on Weblate Try me on Runbot

+

This module was written to extend the functionality of the website popup +newsletter subscription form to support sending to new subscribers an +automatic welcome email and allow you to customize it.

+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Go to Email Marketing > Contacts > Mailing Lists.
  2. +
  3. Edit or create one.
  4. +
  5. Set a Welcome mail template to enable this module’s special behavior when +somebody subscribes to this mailing list. You can use one shipped with +this module, called Welcome mail to newsletter subscribers, +as a starting point.
  6. +
  7. You can also customize this template as you prefer.
  8. +
+

To be used, you also must make sure a subscription snippet for this list exists +somewhere in your website:

+
    +
  1. Go to your website.
  2. +
  3. Navigate to a page where you want to include the subscription widget.
  4. +
  5. Edit the webpage.
  6. +
  7. Drag and drop any Structure or Features block you like.
  8. +
  9. Drag and drop the Inner content > Newsletter block inside it.
  10. +
  11. Choose the same mailing list you configured above.
  12. +
+

Of course, outgoing mail must be properly configured in your instance, or +emails will never be sent.

+
+
+

Usage

+

After you have followed the configuration instructions:

+
    +
  1. Enter as an anonymous user (you can use a browser private window for that).
  2. +
  3. Navigate to the page where the newsletter subscription snippet is found.
  4. +
  5. Enter your email.
  6. +
  7. Hit Subscribe.
  8. +
  9. Check your inbox, you have new mail!
  10. +
+
+
+

Known issues / Roadmap

+
    +
  • Add tests.
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+
    +
  • Tecnativa:
      +
    • Cristina Martin R.
    • +
    • Jairo Llopis
    • +
    +
  • +
+
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/social project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/mass_mailing_newsletter_welcome_mail/views/mail_mass_mailing_list.xml b/mass_mailing_newsletter_welcome_mail/views/mail_mass_mailing_list.xml new file mode 100644 index 00000000..a0c4c9c4 --- /dev/null +++ b/mass_mailing_newsletter_welcome_mail/views/mail_mass_mailing_list.xml @@ -0,0 +1,20 @@ + + + + + + + Add welcome mail template field + mail.mass_mailing.list + + +
+ + + +
+
+
+ +