diff options
| -rw-r--r-- | addons/mass_mailing/__init__.py | 24 | ||||
| -rw-r--r-- | addons/mass_mailing/__openerp__.py | 39 | ||||
| -rw-r--r-- | addons/mass_mailing/mail_mail.py | 35 | ||||
| -rw-r--r-- | addons/mass_mailing/mail_mail_view.xml | 18 | ||||
| -rw-r--r-- | addons/mass_mailing/mass_mailing.py | 84 | ||||
| -rw-r--r-- | addons/mass_mailing/mass_mailing_view.xml | 48 | ||||
| -rw-r--r-- | addons/mass_mailing/security/ir.model.access.csv | 3 | ||||
| -rw-r--r-- | addons/mass_mailing/wizard/__init__.py | 22 | ||||
| -rw-r--r-- | addons/mass_mailing/wizard/mail_compose_message.py | 51 | ||||
| -rw-r--r-- | addons/mass_mailing/wizard/mail_compose_message_view.xml | 20 |
10 files changed, 344 insertions, 0 deletions
diff --git a/addons/mass_mailing/__init__.py b/addons/mass_mailing/__init__.py new file mode 100644 index 00000000000..37f3850306a --- /dev/null +++ b/addons/mass_mailing/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013-today OpenERP SA (<http://www.openerp.com>) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> +# +############################################################################## + +import mass_mailing +import mail_mail +import wizard diff --git a/addons/mass_mailing/__openerp__.py b/addons/mass_mailing/__openerp__.py new file mode 100644 index 00000000000..e6fbb42e886 --- /dev/null +++ b/addons/mass_mailing/__openerp__.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013-today OpenERP SA (<http://www.openerp.com>) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> +# +############################################################################## + +{ + 'name': 'Mass Mailing Campaigns', + 'version': '1.0', + 'author': 'OpenERP', + 'website': 'http://www.openerp.com', + 'category': 'Marketing', + 'depends': ['mail', 'email_template'], + 'description': """TODO""", + 'data': [ + 'mass_mailing_view.xml', + 'mail_mail_view.xml', + 'wizard/mail_compose_message_view.xml', + 'security/ir.model.access.csv', + ], + 'demo': [], + 'installable': True, + 'auto_install': False, +} diff --git a/addons/mass_mailing/mail_mail.py b/addons/mass_mailing/mail_mail.py new file mode 100644 index 00000000000..d7f46446b56 --- /dev/null +++ b/addons/mass_mailing/mail_mail.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013-today OpenERP SA (<http://www.openerp.com>) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> +# +############################################################################## + +from openerp.osv import osv, fields + + +class MailMail(osv.Model): + """Add the mass mailing campaign data to mail""" + _name = 'mail.mail' + _inherit = ['mail.mail'] + + _columns = { + 'mass_mailing_campaign_id': fields.many2one( + 'mail.mass_mailing.campaign', 'Mass Mailing Campaign', + ondelete='set null', + ), + } diff --git a/addons/mass_mailing/mail_mail_view.xml b/addons/mass_mailing/mail_mail_view.xml new file mode 100644 index 00000000000..dd66aede66f --- /dev/null +++ b/addons/mass_mailing/mail_mail_view.xml @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<openerp> + <data> + + <!-- FOLLOWERS !--> + <record model="ir.ui.view" id="mail_mail_form_mass_mailing"> + <field name="name">mail.mail.form.mass_mailing</field> + <field name="model">mail.mail</field> + <field name="inherit_id" ref="mail.view_mail_form"/> + <field name="arch" type="xml"> + <xpath expr="//field[@name='opened']" position="before"> + <field name="mass_mailing_campaign_id"/> + </xpath> + </field> + </record> + + </data> +</openerp> diff --git a/addons/mass_mailing/mass_mailing.py b/addons/mass_mailing/mass_mailing.py new file mode 100644 index 00000000000..91392759b0e --- /dev/null +++ b/addons/mass_mailing/mass_mailing.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013-today OpenERP SA (<http://www.openerp.com>) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> +# +############################################################################## + +from openerp.osv import osv, fields + + +class MassMailingCampaign(osv.Model): + """Model of mass mailing campaigns. + """ + _name = "mail.mass_mailing.campaign" + _description = 'Mass Mailing Campaign' + + def _get_statistics(self, cr, uid, ids, name, arg, context=None): + """ Compute statistics of the mass mailing campaign """ + results = dict.fromkeys(ids, False) + for campaign in self.browse(cr, uid, ids, context=context): + if not campaign.mail_ids: + results[campaign.id] = { + 'sent': 0, + 'opened_ratio': 0.0, + 'replied_ratio': 0.0, + 'bounce_ratio': 0.0, + } + continue + results[campaign.id] = { + 'sent': len(campaign.mail_ids), + 'opened_ratio': len([mail for mail in campaign.mail_ids if mail.opened]) * 1.0 / len(campaign.mail_ids), + 'replied_ratio': len([mail for mail in campaign.mail_ids if mail.replied]) * 1.0 / len(campaign.mail_ids), + 'bounce_ratio': 0.0, + } + return results + + _columns = { + 'name': fields.char( + 'Campaign Name', required=True, + ), + 'template_id': fields.many2one( + 'email.template', 'Email Template', + ondelete='set null', + ), + 'mail_ids': fields.one2many( + 'mail.mail', 'mass_mailing_campaign_id', + 'Send Emails', + ), + # stat fields + 'sent': fields.function( + _get_statistics, + string='Sent Emails', + type='integer', multi='_get_statistics' + ), + 'opened_ratio': fields.function( + _get_statistics, + string='Opened Ratio', + type='float', multi='_get_statistics', + ), + 'replied_ratio': fields.function( + _get_statistics, + string='Replied Ratio', + type='float', multi='_get_statistics' + ), + 'bounce_ratio': fields.function( + _get_statistics, + string='Bounce Ratio', + type='float', multi='_get_statistics' + ), + } diff --git a/addons/mass_mailing/mass_mailing_view.xml b/addons/mass_mailing/mass_mailing_view.xml new file mode 100644 index 00000000000..bc28827343d --- /dev/null +++ b/addons/mass_mailing/mass_mailing_view.xml @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<openerp> + <data> + + <!-- MASS MAILING CAMPAIGNS !--> + <record model="ir.ui.view" id="view_followers_tree"> + <field name="name">mail.mass_mailing.campaign.tree</field> + <field name="model">mail.mass_mailing.campaign</field> + <field name="priority">10</field> + <field name="arch" type="xml"> + <tree string="Mass Mailing Campaigns"> + <field name="name"/> + </tree> + </field> + </record> + + <record model="ir.ui.view" id="view_mail_subscription_form"> + <field name="name">mail.mass_mailing.campaign.form</field> + <field name="model">mail.mass_mailing.campaign</field> + <field name="arch" type="xml"> + <form string="Mass Mailing Campaign" version="7.0"> + <sheet> + <group> + <field name="name"/> + <field name="template_id"/> + <field name="sent"/> + <field name="opened_ratio"/> + <field name="replied_ratio"/> + <field name="bounce_ratio"/> + </group> + </sheet> + </form> + </field> + </record> + + <record id="action_view_mass_mailing_campaigns" model="ir.actions.act_window"> + <field name="name">Mass Mailing Campaigns</field> + <field name="res_model">mail.mass_mailing.campaign</field> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + </record> + + <!-- Add followers related menu entries in Settings/Email --> + <menuitem name="Mass mailing campaigns" id="menu_email_campaigns" parent="base.menu_email" + action="action_view_mass_mailing_campaigns" sequence="60" groups="base.group_no_one"/> + + </data> +</openerp> diff --git a/addons/mass_mailing/security/ir.model.access.csv b/addons/mass_mailing/security/ir.model.access.csv new file mode 100644 index 00000000000..af6eaa7bb06 --- /dev/null +++ b/addons/mass_mailing/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_mass_mailing_campaign,mail.mass_mailing.campaign.template,model_mail_mass_mailing_campaign,,1,1,1,0
+access_mass_mailing_campaign_system,mail.mass_mailing.campaign.system,model_mail_mass_mailing_campaign,base.group_system,1,1,1,1
diff --git a/addons/mass_mailing/wizard/__init__.py b/addons/mass_mailing/wizard/__init__.py new file mode 100644 index 00000000000..155849362cd --- /dev/null +++ b/addons/mass_mailing/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013-today OpenERP SA (<http://www.openerp.com>) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> +# +############################################################################## + +import mail_compose_message diff --git a/addons/mass_mailing/wizard/mail_compose_message.py b/addons/mass_mailing/wizard/mail_compose_message.py new file mode 100644 index 00000000000..2f74ef2c732 --- /dev/null +++ b/addons/mass_mailing/wizard/mail_compose_message.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2013-today OpenERP SA (<http://www.openerp.com>) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/> +# +############################################################################## + +from openerp.osv import osv, fields + + +class MailComposeMessage(osv.TransientModel): + """Add concept of mass mailing campaign to the mail.compose.message wizard + """ + _inherit = 'mail.compose.message' + + _columns = { + 'mass_mail_campaign_id': fields.many2one( + 'mail.mass_mailing.campaign', 'Mass mailing campaign' + ), + } + + def onchange_mass_mail_campaign_id(self, cr, uid, ids, mass_mail_campaign_id, context=None): + values = {} + if mass_mail_campaign_id: + campaign = self.pool['mail.mass_mailing.campaign'].browse(cr, uid, mass_mail_campaign_id, context=context) + if campaign and campaign.template_id: + values['template_id'] = campaign.template_id.id + return {'value': values} + + def render_message(self, cr, uid, wizard, res_id, context=None): + """ Override method that generated the mail content by adding the mass + mailing campaign, when doing pure email mass mailing. """ + res = super(MailComposeMessage, self).render_message(cr, uid, wizard, res_id, context=context) + print res, wizard.mass_mail_campaign_id + if wizard.composition_mode == 'mass_mail' and wizard.mass_mail_campaign_id: # TODO: which kind of mass mailing ? + res['mass_mailing_campaign_id'] = wizard.mass_mail_campaign_id.id + return res diff --git a/addons/mass_mailing/wizard/mail_compose_message_view.xml b/addons/mass_mailing/wizard/mail_compose_message_view.xml new file mode 100644 index 00000000000..bc5f1a9eb6a --- /dev/null +++ b/addons/mass_mailing/wizard/mail_compose_message_view.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <!-- Add mass mail campaign to the mail.compose.message form view --> + <record model="ir.ui.view" id="email_compose_form_mass_mailing"> + <field name="name">mail.compose.message.form.mass_mailing</field> + <field name="model">mail.compose.message</field> + <field name="inherit_id" ref="mail.email_compose_message_wizard_form"/> + <field name="arch" type="xml"> + <xpath expr="//field[@name='subject']" position="after"> + <field name="mass_mail_campaign_id" + on_change="onchange_mass_mail_campaign_id(mass_mail_campaign_id)" + attrs="{'invisible': [('composition_mode', '!=', 'mass_mail')]}"/> + </xpath> + </field> + </record> + + </data> +</openerp> |
