From 48d7a6fa6ca13208ca6468eaee127092fec60c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 14 Apr 2014 16:40:11 +0200 Subject: [PATCH] [CLEAN] mass_mailing: rmeoved dead stuff bzr revid: tde@openerp.com-20140414144011-awu4g35etq9s4gje --- addons/mass_mailing/models/mass_mailing.py | 53 ++----------------- .../static/src/js/mass_mailing.js | 2 +- .../static/src/xml/mass_mailing.xml | 2 +- addons/mass_mailing/views/mass_mailing.xml | 10 ---- .../wizard/mail_compose_message.py | 12 +---- 5 files changed, 8 insertions(+), 71 deletions(-) diff --git a/addons/mass_mailing/models/mass_mailing.py b/addons/mass_mailing/models/mass_mailing.py index b7f40495e36..5ba5bd70f29 100644 --- a/addons/mass_mailing/models/mass_mailing.py +++ b/addons/mass_mailing/models/mass_mailing.py @@ -1,23 +1,4 @@ # -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2013-today OpenERP SA () -# -# 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 -# -############################################################################## from datetime import datetime from dateutil import relativedelta @@ -162,7 +143,7 @@ class MassMailingCampaign(osv.Model): 'mail.mass_mailing', 'mass_mailing_campaign_id', 'Mass Mailings', ), - 'ab_testing': fields.boolean( + 'unique_ab_testing': fields.boolean( 'AB Testing', help='If checked, recipients will be mailed only once, allowing to send' 'various mailings in a single campaign to test the effectiveness' @@ -225,7 +206,7 @@ class MassMailingCampaign(osv.Model): } def get_recipients(self, cr, uid, ids, model=None, context=None): - """Return the recipints of a mailing campaign. This is based on the statistics + """Return the recipients of a mailing campaign. This is based on the statistics build for each mailing. """ Statistics = self.pool['mail.mail.statistics'] res = dict.fromkeys(ids, False) @@ -317,20 +298,6 @@ class MassMailing(osv.Model): results[mid]['replied_ratio'] = 100.0 * results[mid]['replied'] / (results[mid]['sent'] or 1) return results - def _get_contact_nbr(self, cr, uid, ids, name, arg, context=None): - res = dict.fromkeys(ids, False) - for mailing in self.browse(cr, uid, ids, context=context): - val = {'contact_nbr': 0, 'contact_ab_nbr': 0} # 'contact_ab_done': 0 - val['contact_nbr'] = self.pool[mailing.mailing_model].search( - cr, uid, eval(mailing.mailing_domain), - count=True, context=context - ) - # val['contact_ab_nbr'] = int(val['contact_nbr'] * mailing.contact_ab_pc / 100.0) - # if mailing.mass_mailing_campaign_id and mailing.ab_testing: - # val['contact_ab_done'] = len(self.pool['mail.mass_mailing.campaign'].get_recipients(cr, uid, [mailing.mass_mailing_campaign_id.id], context=context)[mailing.mass_mailing_campaign_id.id]) - res[mailing.id] = val - return res - def _get_private_models(self, context=None): return ['res.partner', 'mail.mass_mailing.contact'] @@ -382,10 +349,6 @@ class MassMailing(osv.Model): 'mail.mass_mailing.list', 'mail_mass_mailing_list_rel', string='Mailing Lists', ), - 'contact_nbr': fields.function( - _get_contact_nbr, type='integer', multi='_get_contact_nbr', - string='Contact Number' - ), 'contact_ab_pc': fields.integer( 'AB Testing percentage', help='Percentage of the contacts that will be mailed. Recipients will be taken randomly.' @@ -507,17 +470,13 @@ class MassMailing(osv.Model): def on_change_model(self, cr, uid, ids, mailing_model, list_ids, context=None): value = {} - if mailing_model=='mail.mass_mailing.contact': - if list_ids and list_ids[0][0]==6 and list_ids[0][2]: + if mailing_model is 'mail.mass_mailing.contact': + if list_ids and list_ids[0][0] == 6 and list_ids[0][2]: value['mailing_domain'] = "[('list_id', 'in', ["+','.join(map(str, list_ids[0][2]))+"])]" else: value['mailing_domain'] = "[('list_id', '=', False)]" - value['contact_nbr'] = self.pool[mailing_model].search( - cr, uid, eval(value['mailing_domain']), count=True, context=context - ) else: value['mailing_domain'] = False - value['contact_nbr'] = 0 return {'value': value} def on_change_reply_specified(self, cr, uid, ids, reply_specified, reply_in_thread, context=None): @@ -538,7 +497,7 @@ class MassMailing(osv.Model): list_ids += command[2] if list_ids: values['contact_nbr'] = self.pool[mailing_model].search( - cr, uid, [('list_id', 'in', list_ids), ('opt_out','!=',1)], + cr, uid, [('list_id', 'in', list_ids), ('opt_out', '!=', True)], count=True, context=context ) else: @@ -665,5 +624,3 @@ class MassMailing(osv.Model): self.pool['mail.compose.message'].send_mail(cr, uid, [composer_id], context=comp_ctx) self.write(cr, uid, [mailing.id], {'date': fields.datetime.now(), 'state': 'done'}, context=context) return True - - diff --git a/addons/mass_mailing/static/src/js/mass_mailing.js b/addons/mass_mailing/static/src/js/mass_mailing.js index cf4927e908e..58590001355 100644 --- a/addons/mass_mailing/static/src/js/mass_mailing.js +++ b/addons/mass_mailing/static/src/js/mass_mailing.js @@ -19,7 +19,7 @@ openerp.mass_mailing = function (instance) { start: function() { var self=this; this._super.apply(this, arguments); - $('button', this.$el).on('click', self.on_click); + $('button.select_records', this.$el).on('click', self.on_click); this.set_button(); }, set_button: function() { diff --git a/addons/mass_mailing/static/src/xml/mass_mailing.xml b/addons/mass_mailing/static/src/xml/mass_mailing.xml index 2b20e450113..e9c3299cc30 100644 --- a/addons/mass_mailing/static/src/xml/mass_mailing.xml +++ b/addons/mass_mailing/static/src/xml/mass_mailing.xml @@ -3,7 +3,7 @@
-
-
-
- - Recipients - -
- diff --git a/addons/mass_mailing/wizard/mail_compose_message.py b/addons/mass_mailing/wizard/mail_compose_message.py index b10cafdcc4e..20a2c217d8b 100644 --- a/addons/mass_mailing/wizard/mail_compose_message.py +++ b/addons/mass_mailing/wizard/mail_compose_message.py @@ -50,16 +50,6 @@ class MailComposeMessage(osv.TransientModel): if wizard.composition_mode == 'mass_mail' and \ (wizard.mass_mailing_name or wizard.mass_mailing_id) and \ wizard.model in [item[0] for item in self.pool['mail.mass_mailing']._get_mailing_model(cr, uid, context=context)]: - # list_ids = None - # if wizard.mailing_list_ids: - # list_ids = [l.id for l in wizard.mailing_list_ids] - # if not list_ids: - # list_ids = [self.pool['mail.mass_mailing.list'].create( - # cr, uid, { - # 'name': wizard.mass_mailing_name, - # 'model': wizard.model, - # 'domain': wizard.active_domain, - # }, context=context)] mass_mailing = wizard.mass_mailing_id if not mass_mailing: mass_mailing_id = self.pool['mail.mass_mailing'].create( @@ -69,7 +59,7 @@ class MailComposeMessage(osv.TransientModel): 'template_id': wizard.template_id and wizard.template_id.id or False, 'state': 'done', 'mailing_type': wizard.model, - # 'contact_list_ids': [(4, list_id) for list_id in list_ids], + 'mailing_domain': wizard.active_domain, }, context=context) mass_mailing = self.pool['mail.mass_mailing'].browse(cr, uid, mass_mailing_id, context=context) recipient_values = self.pool['mail.mass_mailing'].get_recipients_data(cr, uid, mass_mailing, res_ids, context=context)