Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12.0 mig mass_mailing_custom_unsubscribe #402

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6cbc6a9
[ADD] mass_mailing_custom_unsubscribe addon
antespi Aug 19, 2015
2da2ab2
OCA Transbot updated translations from Transifex
oca-transbot Sep 13, 2015
75f2b13
[MIG] Make modules uninstallable
pedrobaeza Oct 14, 2015
c09b6e1
[FIX] remove en.po that was erroneously created by transbot
sbidoul Aug 15, 2016
11e3133
[MIG] Rename manifest files
pedrobaeza Oct 6, 2016
db7ea5f
Add beautier pages for unsubscription process.
yajo Sep 25, 2015
f24fda3
[8.0][IMP][mass_mailing_custom_unsubscribe] Get reasons for unsubscri…
yajo Jul 25, 2016
96e2743
[9.0][MIG][mass_mailing_custom_unsubscribe] Migrate.
yajo Nov 11, 2016
d99961a
OCA Transbot updated translations from Transifex
oca-transbot Sep 13, 2015
ad68bf6
[MIG][mass_mailing_custom_unsubscribe] Migrate to v10
yajo Jul 5, 2017
07ab8a7
OCA Transbot updated translations from Transifex
oca-transbot Jul 22, 2017
e25aff7
[IMP] mass_mailing_custom_unsubscribe: GDPR compliance (#267)
yajo May 10, 2018
35df61a
[MIG] mass_mailing_custom_unsubscribe: Migration to 11.0
chienandalu May 25, 2018
68cb82e
[FIX] do not use section titles in readme fragments
sbidoul Jun 16, 2018
f57433a
[UPD] Update mass_mailing_custom_unsubscribe.pot
oca-travis Jun 17, 2018
232e279
Translated using Weblate (French)
didierdonze Jun 18, 2018
345f579
mass_mailing_custom_unsubscribe: Fix testing error
ernestotejeda Jun 19, 2018
d51e00f
[UPD] Update mass_mailing_custom_unsubscribe.pot
oca-travis Jun 20, 2018
573ab59
[UPD] README.rst
OCA-git-bot Jun 18, 2018
907546c
Update translation files
oca-transbot Nov 29, 2018
fd6344b
[MIG] mass_mailing_custom_unsubscribe: Migration to 12.0
ernestotejeda Apr 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions mass_mailing_custom_unsubscribe/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
==========================================================
Customizable unsubscription process on mass mailing emails
==========================================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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/12.0/mass_mailing_custom_unsubscribe
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-12-0/social-12-0-mass_mailing_custom_unsubscribe
: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/12.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This addon extends the unsubscription form to let you:

- Choose which mailing lists are not cross-unsubscriptable when unsubscribing
from a different one.
- Know why and when a contact has been subscribed or unsubscribed from a
mass mailing.
- Provide proof on why you are sending mass mailings to a given contact, as
required by the GDPR in Europe.

**Table of contents**

.. contents::
:local:

Configuration
=============

You can customize what reasons will be displayed to your unsubscriptors when
they are going to unsubscribe. To do it:

#. Go to *Email Marketing > Configuration > Unsubscription Reasons*.
#. Create / edit / remove / sort as usual.
#. If *Details required* is enabled, they will have to fill a text area to
continue.

Usage
=====

Once configured:

#. Go to *Email Marketing > Mailings > Create*.
#. Edit your mass mailing at wish, but remember to add a snippet from
*Footers*, so people have an *Unsubscribe* link.
#. Send it.
#. If somebody gets unsubscribed, you will see logs about that under
*Email Marketing > Unsubscriptions*.

Known issues / Roadmap
======================

* This module replaces AJAX submission core implementation from the mailing
list management form, because it is impossible to extend it. When this is
fixed, this addon will need a refactoring (mostly removing
duplicated functionality and depending on it instead of replacing it).

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/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 <https://github.com/OCA/social/issues/new?body=module:%20mass_mailing_custom_unsubscribe%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* `Tecnativa <https://www.tecnativa.com>`_:

* Rafael Blasco
* Antonio Espinosa
* Jairo Llopis
* David Vidal
* Ernesto Tejeda

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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 <https://github.com/OCA/social/tree/12.0/mass_mailing_custom_unsubscribe>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions mass_mailing_custom_unsubscribe/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import controllers
from . import models
33 changes: 33 additions & 0 deletions mass_mailing_custom_unsubscribe/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# Copyright 2018 David Vidal <david.vidal@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Customizable unsubscription process on mass mailing emails',
'summary': 'Know and track (un)subscription reasons, GDPR compliant',
'category': 'Marketing',
'version': '12.0.1.0.0',
'depends': [
'mass_mailing',
],
'data': [
'security/ir.model.access.csv',
'data/mail_unsubscription_reason.xml',
'templates/general_reason_form.xml',
'templates/mass_mailing_contact_reason.xml',
'views/assets.xml',
'views/mail_unsubscription_reason_view.xml',
'views/mail_mass_mailing_list_view.xml',
'views/mail_unsubscription_view.xml',
],
'demo': [
'demo/assets.xml',
],
'images': [
'images/form.png',
],
'author': 'Tecnativa,'
'Odoo Community Association (OCA)',
'website': 'https://github.com/OCA/social',
'license': 'AGPL-3',
'installable': True,
}
4 changes: 4 additions & 0 deletions mass_mailing_custom_unsubscribe/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import main
121 changes: 121 additions & 0 deletions mass_mailing_custom_unsubscribe/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Copyright 2015 Antiun Ingeniería S.L. (http://www.antiun.com)
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import logging

from odoo.http import request, route
from odoo.addons.mass_mailing.controllers.main import MassMailController

_logger = logging.getLogger(__name__)


class CustomUnsubscribe(MassMailController):
def reason_form(self, mailing_id, email, res_id, reasons, token):
"""Get the unsubscription reason form.

:param mail.mass_mailing mailing:
Mailing where the unsubscription is being processed.

:param str email:
Email to be unsubscribed.

:param int res_id:
ID of the unsubscriber.

:param str token:
Security token for unsubscriptions.
"""
return request.render(
"mass_mailing_custom_unsubscribe.reason_form",
{
"email": email,
"mailing_id": mailing_id,
"reasons": reasons,
"res_id": res_id,
"token": token,
})

@route()
def mailing(self, mailing_id, email=None, res_id=None, token="", **post):
"""Ask/save unsubscription reason."""
_logger.debug(
"Called `mailing()` with: %r",
(mailing_id, email, res_id, token, post))
reasons = request.env["mail.unsubscription.reason"].search([])
try:
# Check if we already have a reason for unsubscription
reason_id = int(post["reason_id"])
except (KeyError, ValueError):
# No reasons? Ask for them
return self.reason_form(mailing_id, email, res_id, reasons, token)
else:
# Unsubscribe, saving reason and details by context
details = post.get("details", False)
self._add_extra_context(mailing_id, res_id, reason_id, details)
# You could get a DetailsRequiredError here, but only if HTML5
# validation fails, which should not happen in modern browsers
result = super().mailing(
mailing_id, email, res_id, token=token, **post)
result.qcontext.update({"reasons": reasons})
# update list_ids taking into account not_cross_unsubscriptable
# field
mailing_obj = request.env['mail.mass_mailing']
mailing = mailing_obj.sudo().browse(mailing_id)
if mailing.mailing_model_real == 'mail.mass_mailing.contact':
result.qcontext.update({
"list_ids": result.qcontext["list_ids"].filtered(
lambda mailing_list:
not mailing_list.not_cross_unsubscriptable or
mailing_list in mailing.contact_list_ids
)
})
return result

@route()
def unsubscribe(self, mailing_id, opt_in_ids, opt_out_ids, email, res_id,
token, reason_id=None, details=None):
"""Store unsubscription reasons when unsubscribing from RPC."""
# Update request context
self._add_extra_context(mailing_id, res_id, reason_id, details)
_logger.debug(
"Called `unsubscribe()` with: %r",
(mailing_id, opt_in_ids, opt_out_ids, email, res_id, token,
reason_id, details))
return super().unsubscribe(
mailing_id, opt_in_ids, opt_out_ids, email, res_id, token)

@route()
def blacklist_add(self, mailing_id, res_id, email, token, reason_id=None,
details=None):
self._add_extra_context(mailing_id, res_id, reason_id, details)
return super().blacklist_add(
mailing_id, res_id, email, token)

@route()
def blacklist_remove(self, mailing_id, res_id, email, token,
reason_id=None, details=None):
self._add_extra_context(mailing_id, res_id, reason_id, details)
return super().blacklist_remove(
mailing_id, res_id, email, token)

def _add_extra_context(self, mailing_id, res_id, reason_id, details):
environ = request.httprequest.headers.environ
# Add mailing_id and res_id to request.context to be used in the
# redefinition of _add and _remove methods of the mail.blacklist class
extra_context = {
"default_metadata": "\n".join(
"%s: %s" % (val, environ.get(val)) for val in (
"REMOTE_ADDR",
"HTTP_USER_AGENT",
"HTTP_ACCEPT_LANGUAGE",
)
),
"mailing_id": mailing_id,
"unsubscription_res_id": int(res_id),
}
if reason_id:
extra_context["default_reason_id"] = int(reason_id)
if details:
extra_context["default_details"] = details
request.context = dict(request.context, **extra_context)
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<data noupdate="1">

<record id="reason_not_interested"
model="mail.unsubscription.reason"
forcecreate="False">
<field name="name">I'm not interested</field>
<field name="sequence">10</field>
<field name="details_required" eval="False"/>
</record>

<record id="reason_not_requested"
model="mail.unsubscription.reason"
forcecreate="False">
<field name="name">I did not request this</field>
<field name="sequence">20</field>
<field name="details_required" eval="False"/>
</record>

<record id="reason_too_many"
model="mail.unsubscription.reason"
forcecreate="False">
<field name="name">I get too many emails</field>
<field name="sequence">30</field>
<field name="details_required" eval="False"/>
</record>

<record id="reason_other"
model="mail.unsubscription.reason"
forcecreate="False">
<field name="name">Other reason</field>
<field name="sequence">100</field>
<field name="details_required" eval="True"/>
</record>

</data>
25 changes: 25 additions & 0 deletions mass_mailing_custom_unsubscribe/demo/assets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<odoo>

<template id="assets_frontend_demo"
inherit_id="web.assets_frontend">
<xpath expr=".">
<script type="text/javascript"
src="/mass_mailing_custom_unsubscribe/static/src/js/contact.tour.js"/>
<script type="text/javascript"
src="/mass_mailing_custom_unsubscribe/static/src/js/partner.tour.js"/>
</xpath>
</template>

<!--This is set here to make tours work-->
<template id="mass_mailing_custom_unsubscribe.layout"
inherit_id="mass_mailing.layout">
<xpath expr="//t[@t-set='head']" position="inside">
<t t-call="web.assets_frontend"/>
</xpath>
</template>

</odoo>
12 changes: 12 additions & 0 deletions mass_mailing_custom_unsubscribe/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import exceptions


class DetailsRequiredError(exceptions.ValidationError):
pass


class ReasonRequiredError(exceptions.ValidationError):
pass
Loading