forked from OCA/social
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b9e0602
commit b9e0f57
Showing
16 changed files
with
521 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
================== | ||
Mass mailing event | ||
================== | ||
|
||
This module links ``mass_mailing`` with ``event`` in order to exclude | ||
recipients that are already registered, confirmed, cancelled, attended, or a | ||
combination of these states, when the mass mailing is sent. | ||
|
||
Usage | ||
===== | ||
|
||
In a mass mailing, users can set an event related and exclude the recipients who | ||
have an email address already registered in that event. | ||
|
||
This is useful in this scenario: | ||
|
||
1. Create a mass mailing for telling to 1000 partners that a new event is | ||
available. | ||
2. During a week some of them (50) have been registered in the event | ||
3. Then, a week after the first mass mailing, duplicate it to get a second | ||
mass mailing. Relate this one to the event and exclude the registered emails. | ||
Change the message body to remember that early bird period is going to expire | ||
soon. | ||
4. Send the second mass mailing and registered emails are automatically excluded, | ||
So it's been only sent to 950 partners the ones who are not registered in the | ||
event yet. | ||
|
||
|
||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas | ||
:alt: Try me on Runbot | ||
:target: https://runbot.odoo-community.org/runbot/205/8.0 | ||
|
||
|
||
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. | ||
|
||
Credits | ||
======= | ||
|
||
Images | ||
------ | ||
|
||
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_. | ||
|
||
Contributors | ||
------------ | ||
|
||
* Antonio Espinosa <[email protected]> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
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. | ||
|
||
To contribute to this module, please visit https://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Antonio Espinosa <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Mass mailing event", | ||
"summary": "Link mass mailing with event for excluding recipients", | ||
"version": "8.0.1.0.0", | ||
"category": "Marketing", | ||
"website": "https://odoo-community.org/", | ||
"author": "Tecnativa, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": [ | ||
"mass_mailing", | ||
"event", | ||
], | ||
"data": [ | ||
"security/ir.model.access.csv", | ||
"data/event_state_data.xml", | ||
"views/mass_mailing_view.xml", | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2016 Antonio Espinosa <[email protected]> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
|
||
<openerp> | ||
<data> | ||
|
||
<record id="event_draft" model="event.registration.state"> | ||
<field name="name">Unconfirmed</field> | ||
<field name="code">draft</field> | ||
</record> | ||
|
||
<record id="event_cancel" model="event.registration.state"> | ||
<field name="name">Cancelled</field> | ||
<field name="code">cancel</field> | ||
</record> | ||
|
||
<record id="event_open" model="event.registration.state"> | ||
<field name="name">Confirmed</field> | ||
<field name="code">open</field> | ||
</record> | ||
|
||
<record id="event_done" model="event.registration.state"> | ||
<field name="name">Attended</field> | ||
<field name="code">done</field> | ||
</record> | ||
|
||
</data> | ||
</openerp> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * mass_mailing_event | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 8.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2016-11-07 11:16+0000\n" | ||
"PO-Revision-Date: 2016-11-07 11:16+0000\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: mass_mailing_event | ||
#: field:event.registration.state,code:0 | ||
msgid "Code" | ||
msgstr "Código" | ||
|
||
#. module: mass_mailing_event | ||
#: field:event.registration.state,create_uid:0 | ||
msgid "Created by" | ||
msgstr "Creado por" | ||
|
||
#. module: mass_mailing_event | ||
#: field:event.registration.state,create_date:0 | ||
msgid "Created on" | ||
msgstr "Creado en" | ||
|
||
#. module: mass_mailing_event | ||
#: field:event.registration.state,display_name:0 | ||
msgid "Display Name" | ||
msgstr "Nombre mostrado" | ||
|
||
#. module: mass_mailing_event | ||
#: model:ir.model,name:mass_mailing_event.model_event_registration | ||
msgid "Event Registration" | ||
msgstr "Registro de evento" | ||
|
||
#. module: mass_mailing_event | ||
#: field:mail.mass_mailing,event_id:0 | ||
msgid "Event related" | ||
msgstr "Evento relacionado" | ||
|
||
#. module: mass_mailing_event | ||
#: field:mail.mass_mailing,exclude_event_state_ids:0 | ||
msgid "Exclude" | ||
msgstr "Excluir" | ||
|
||
#. module: mass_mailing_event | ||
#: field:event.registration.state,id:0 | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: mass_mailing_event | ||
#: field:event.registration.state,__last_update:0 | ||
msgid "Last Modified on" | ||
msgstr "Última modificación en" | ||
|
||
#. module: mass_mailing_event | ||
#: field:event.registration.state,write_uid:0 | ||
msgid "Last Updated by" | ||
msgstr "Última actualización por" | ||
|
||
#. module: mass_mailing_event | ||
#: field:event.registration.state,write_date:0 | ||
msgid "Last Updated on" | ||
msgstr "Última actualización en" | ||
|
||
#. module: mass_mailing_event | ||
#: model:ir.model,name:mass_mailing_event.model_mail_mass_mailing | ||
msgid "Mass Mailing" | ||
msgstr "Envío masivo" | ||
|
||
#. module: mass_mailing_event | ||
#: model:ir.model,name:mass_mailing_event.model_mail_mass_mailing_contact | ||
msgid "Mass Mailing Contact" | ||
msgstr "Contacto" | ||
|
||
#. module: mass_mailing_event | ||
#: field:event.registration.state,name:0 | ||
msgid "Name" | ||
msgstr "Nombre" | ||
|
||
#. module: mass_mailing_event | ||
#: model:ir.model,name:mass_mailing_event.model_res_partner | ||
msgid "Partner" | ||
msgstr "Empresa" | ||
|
||
#. module: mass_mailing_event | ||
#: view:mail.mass_mailing:mass_mailing_event.view_mail_mass_mailing_form | ||
msgid "{'search_default_not_opt_out': 1, 'exclude_mass_mailing': active_id}" | ||
msgstr "{'search_default_not_opt_out': 1, 'exclude_mass_mailing': active_id}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- coding: utf-8 -*- | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import event_registration_state | ||
from . import mail_mass_mailing | ||
from . import mail_mass_mailing_contact | ||
from . import res_partner | ||
from . import event_registration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Antonio Espinosa <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, api | ||
from .mail_mass_mailing import event_filtered_ids | ||
|
||
|
||
class EventRegistration(models.Model): | ||
_inherit = 'event.registration' | ||
|
||
@api.model | ||
def search_count(self, domain): | ||
res = super(EventRegistration, self).search_count(domain) | ||
mass_mailing_id = self.env.context.get('exclude_mass_mailing', False) | ||
if mass_mailing_id: | ||
res_ids = event_filtered_ids( | ||
self, mass_mailing_id, domain, field='email') | ||
return len(res_ids) if res_ids else 0 | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Antonio Espinosa <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, fields | ||
|
||
|
||
class EventRegistrationState(models.Model): | ||
_name = 'event.registration.state' | ||
|
||
name = fields.Char(required=True) | ||
code = fields.Char(required=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Antonio Espinosa <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
import copy | ||
from openerp import models, fields, api | ||
|
||
|
||
def event_filtered_ids(model, mass_mailing_id, domain, field='email'): | ||
field = field or 'email' | ||
domain = domain or [] | ||
exclude_emails = [] | ||
mass_mailing = model.env['mail.mass_mailing'].browse(mass_mailing_id) | ||
if mass_mailing.event_id: | ||
exclude = mass_mailing.exclude_event_state_ids.mapped('code') | ||
reg_domain = False | ||
registrations = model.env['event.registration'] | ||
if exclude: | ||
reg_domain = [ | ||
('event_id', '=', mass_mailing.event_id.id), | ||
('state', 'in', exclude) | ||
] | ||
if reg_domain: | ||
registrations = registrations.search(reg_domain) | ||
if registrations: | ||
exclude_emails = registrations.mapped('email') | ||
apply_domain = copy.deepcopy(domain) | ||
if exclude_emails: | ||
apply_domain.append((field, 'not in', exclude_emails)) | ||
rows = model.search(apply_domain) | ||
return rows.ids | ||
|
||
|
||
class MailMassMailing(models.Model): | ||
_inherit = 'mail.mass_mailing' | ||
|
||
def _default_exclude_event_state_ids(self): | ||
return self.env['event.registration.state'].search([]) | ||
|
||
event_id = fields.Many2one( | ||
string="Event related", comodel_name='event.event') | ||
exclude_event_state_ids = fields.Many2many( | ||
comodel_name='event.registration.state', | ||
string="Exclude", default=_default_exclude_event_state_ids) | ||
|
||
@api.model | ||
def get_recipients(self, mailing): | ||
res_ids = super(MailMassMailing, self).get_recipients(mailing) | ||
if res_ids: | ||
domain = [('id', 'in', res_ids)] | ||
return event_filtered_ids( | ||
self.env[mailing.mailing_model], mailing.id, domain, | ||
field='email') | ||
return res_ids |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Antonio Espinosa <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, api | ||
from .mail_mass_mailing import event_filtered_ids | ||
|
||
|
||
class MailMassMailingContact(models.Model): | ||
_inherit = 'mail.mass_mailing.contact' | ||
|
||
@api.model | ||
def search_count(self, domain): | ||
res = super(MailMassMailingContact, self).search_count(domain) | ||
mass_mailing_id = self.env.context.get('exclude_mass_mailing', False) | ||
if mass_mailing_id: | ||
res_ids = event_filtered_ids( | ||
self, mass_mailing_id, domain, field='email') | ||
return len(res_ids) if res_ids else 0 | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2016 Antonio Espinosa <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from openerp import models, api | ||
from .mail_mass_mailing import event_filtered_ids | ||
|
||
|
||
class ResPartner(models.Model): | ||
_inherit = 'res.partner' | ||
|
||
@api.model | ||
def search_count(self, domain): | ||
res = super(ResPartner, self).search_count(domain) | ||
mass_mailing_id = self.env.context.get('exclude_mass_mailing', False) | ||
if mass_mailing_id: | ||
res_ids = event_filtered_ids( | ||
self, mass_mailing_id, domain, field='email') | ||
return len(res_ids) if res_ids else 0 | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" | ||
"access_event_registration_state_group_user","event_registration_state group_user","model_event_registration_state","base.group_user",1,0,0,0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
|
||
from . import test_mass_mailing_event |
Oops, something went wrong.