[IMP] mail, mass_mailing: using a _mail_mass_mailing class attribute
it is now possible to compute models allowing mass mailing using mass_mailing_campaign module. This allows to completely remove the bridges modules, using a more generic controller for unsubscription. bzr revid: tde@openerp.com-20140416082851-8duo6yrwr5hwd8c2
This commit is contained in:
parent
c5627c4d3f
commit
4336c64a7c
|
@ -79,6 +79,7 @@ class crm_lead(format_address, osv.osv):
|
||||||
'crm.mt_lead_lost': lambda self, cr, uid, obj, ctx=None: obj.probability == 0 and obj.stage_id and obj.stage_id.fold and obj.stage_id.sequence > 1,
|
'crm.mt_lead_lost': lambda self, cr, uid, obj, ctx=None: obj.probability == 0 and obj.stage_id and obj.stage_id.fold and obj.stage_id.sequence > 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
_mail_mass_mailing = _('Leads / Opportunities')
|
||||||
|
|
||||||
def get_empty_list_help(self, cr, uid, help, context=None):
|
def get_empty_list_help(self, cr, uid, help, context=None):
|
||||||
if context.get('default_type') == 'lead':
|
if context.get('default_type') == 'lead':
|
||||||
|
|
|
@ -80,6 +80,7 @@ class hr_applicant(osv.Model):
|
||||||
_description = "Applicant"
|
_description = "Applicant"
|
||||||
_order = "id desc"
|
_order = "id desc"
|
||||||
_inherit = ['mail.thread', 'ir.needaction_mixin']
|
_inherit = ['mail.thread', 'ir.needaction_mixin']
|
||||||
|
|
||||||
_track = {
|
_track = {
|
||||||
'stage_id': {
|
'stage_id': {
|
||||||
# this is only an heuristics; depending on your particular stage configuration it may not match all 'new' stages
|
# this is only an heuristics; depending on your particular stage configuration it may not match all 'new' stages
|
||||||
|
@ -87,6 +88,7 @@ class hr_applicant(osv.Model):
|
||||||
'hr_recruitment.mt_applicant_stage_changed': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.sequence > 1,
|
'hr_recruitment.mt_applicant_stage_changed': lambda self, cr, uid, obj, ctx=None: obj.stage_id and obj.stage_id.sequence > 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
_mail_mass_mailing = _('Applicants')
|
||||||
|
|
||||||
def _get_default_department_id(self, cr, uid, context=None):
|
def _get_default_department_id(self, cr, uid, context=None):
|
||||||
""" Gives default department by checking if present in the context """
|
""" Gives default department by checking if present in the context """
|
||||||
|
|
|
@ -96,6 +96,9 @@ class mail_thread(osv.AbstractModel):
|
||||||
# :param function lambda: returns whether the tracking should record using this subtype
|
# :param function lambda: returns whether the tracking should record using this subtype
|
||||||
_track = {}
|
_track = {}
|
||||||
|
|
||||||
|
# Mass mailing feature
|
||||||
|
_mail_mass_mailing = False
|
||||||
|
|
||||||
def get_empty_list_help(self, cr, uid, help, context=None):
|
def get_empty_list_help(self, cr, uid, help, context=None):
|
||||||
""" Override of BaseModel.get_empty_list_help() to generate an help message
|
""" Override of BaseModel.get_empty_list_help() to generate an help message
|
||||||
that adds alias information. """
|
that adds alias information. """
|
||||||
|
|
|
@ -28,6 +28,7 @@ class res_partner_mail(osv.Model):
|
||||||
_name = "res.partner"
|
_name = "res.partner"
|
||||||
_inherit = ['res.partner', 'mail.thread']
|
_inherit = ['res.partner', 'mail.thread']
|
||||||
_mail_flat_thread = False
|
_mail_flat_thread = False
|
||||||
|
_mail_mass_mailing = _('Customers')
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'notification_email_send': fields.selection([
|
'notification_email_send': fields.selection([
|
||||||
|
|
|
@ -30,6 +30,13 @@ class MassMailController(http.Controller):
|
||||||
record_ids = request.registry[mailing.mailing_model].search(cr, SUPERUSER_ID, [('list_id', 'in', list_ids), ('id', '=', res_id), ('email', 'ilike', email)], context=context)
|
record_ids = request.registry[mailing.mailing_model].search(cr, SUPERUSER_ID, [('list_id', 'in', list_ids), ('id', '=', res_id), ('email', 'ilike', email)], context=context)
|
||||||
request.registry[mailing.mailing_model].write(cr, SUPERUSER_ID, record_ids, {'opt_out': True}, context=context)
|
request.registry[mailing.mailing_model].write(cr, SUPERUSER_ID, record_ids, {'opt_out': True}, context=context)
|
||||||
else:
|
else:
|
||||||
record_ids = request.registry[mailing.mailing_model].search(cr, SUPERUSER_ID, [('id', '=', res_id), ('email', 'ilike', email)], context=context)
|
email_fname = None
|
||||||
request.registry[mailing.mailing_model].write(cr, SUPERUSER_ID, record_ids, {'opt_out': True}, context=context)
|
if 'email_from' in request.registry[mailing.mailing_model]._all_columns:
|
||||||
|
email_fname = 'email_from'
|
||||||
|
elif 'email' in request.registry[mailing.mailing_model]._all_columns:
|
||||||
|
email_fname = 'email'
|
||||||
|
if email_fname:
|
||||||
|
record_ids = request.registry[mailing.mailing_model].search(cr, SUPERUSER_ID, [('id', '=', res_id), (email_fname, 'ilike', email)], context=context)
|
||||||
|
if 'opt_out' in request.registry[mailing.mailing_model]._all_columns:
|
||||||
|
request.registry[mailing.mailing_model].write(cr, SUPERUSER_ID, record_ids, {'opt_out': True}, context=context)
|
||||||
return 'OK'
|
return 'OK'
|
||||||
|
|
|
@ -299,10 +299,13 @@ class MassMailing(osv.Model):
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def _get_mailing_model(self, cr, uid, context=None):
|
def _get_mailing_model(self, cr, uid, context=None):
|
||||||
return [
|
res = []
|
||||||
('res.partner', _('Customers')),
|
for model_name in self.pool:
|
||||||
('mail.mass_mailing.contact', _('Mailing List'))
|
model = self.pool[model_name]
|
||||||
]
|
if hasattr(model, '_mail_mass_mailing') and getattr(model, '_mail_mass_mailing'):
|
||||||
|
res.append((model._name, getattr(model, '_mail_mass_mailing')))
|
||||||
|
res.append(('mail.mass_mailing.contact', _('Mailing List')))
|
||||||
|
return res
|
||||||
|
|
||||||
# indirections for inheritance
|
# indirections for inheritance
|
||||||
_mailing_model = lambda self, *args, **kwargs: self._get_mailing_model(*args, **kwargs)
|
_mailing_model = lambda self, *args, **kwargs: self._get_mailing_model(*args, **kwargs)
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# Copyright (C) 2014-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 models
|
|
||||||
import controllers
|
|
|
@ -1,17 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
{
|
|
||||||
'name': 'Mass Mailing with Recruitment',
|
|
||||||
'version': '1.0',
|
|
||||||
'depends': ['mass_mailing', 'hr_recruitment'],
|
|
||||||
'author': 'OpenERP SA',
|
|
||||||
'category': 'Hidden/Dependency',
|
|
||||||
'description': """
|
|
||||||
Bridge module between Mass Mailing and HR Recruitment
|
|
||||||
""",
|
|
||||||
'website': 'http://www.openerp.com',
|
|
||||||
'data': [],
|
|
||||||
'demo': [],
|
|
||||||
'installable': True,
|
|
||||||
'auto_install': True,
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
import main
|
|
|
@ -1,21 +0,0 @@
|
||||||
|
|
||||||
from openerp import http, SUPERUSER_ID
|
|
||||||
from openerp.addons.mass_mailing.controllers import main
|
|
||||||
from openerp.http import request
|
|
||||||
|
|
||||||
|
|
||||||
class MassMailController(main.MassMailController):
|
|
||||||
|
|
||||||
@http.route(['/mail/mailing/<int:mailing_id>/unsubscribe'], type='http', auth='none')
|
|
||||||
def mailing(self, mailing_id, email=None, res_id=None, **post):
|
|
||||||
cr, uid, context = request.cr, request.uid, request.context
|
|
||||||
MassMailing = request.registry['mail.mass_mailing']
|
|
||||||
mailing_ids = MassMailing.exists(cr, SUPERUSER_ID, [mailing_id], context=context)
|
|
||||||
if not mailing_ids:
|
|
||||||
return super(MassMailController, self).mailing(mailing_id, email=email, res_id=res_id, **post)
|
|
||||||
mailing = MassMailing.browse(cr, SUPERUSER_ID, mailing_ids[0], context=context)
|
|
||||||
if mailing.mailing_model == 'hr.applicant':
|
|
||||||
record_ids = request.registry[mailing.mailing_model].search(cr, SUPERUSER_ID, [('id', '=', res_id), ('email_from', 'ilike', email)], context=context)
|
|
||||||
# request.registry[mailing.mailing_model].write(cr, SUPERUSER_ID, record_ids, {'opt_out': True}, context=context)
|
|
||||||
return 'OK'
|
|
||||||
return super(MassMailController, self).mailing(mailing_id, email=email, res_id=res_id, **post)
|
|
|
@ -1 +0,0 @@
|
||||||
import mass_mailing
|
|
|
@ -1,14 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from openerp.osv import osv
|
|
||||||
|
|
||||||
|
|
||||||
class MassMailing(osv.Model):
|
|
||||||
"""Inherit to add hr.applicant objects available for mass mailing """
|
|
||||||
_name = 'mail.mass_mailing'
|
|
||||||
_inherit = 'mail.mass_mailing'
|
|
||||||
|
|
||||||
def _get_mailing_model(self, cr, uid, context=None):
|
|
||||||
res = super(MassMailing, self)._get_mailing_model(cr, uid, context=context)
|
|
||||||
res.append(('hr.applicant', 'Applicants'))
|
|
||||||
return res
|
|
|
@ -1,23 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# OpenERP, Open Source Management Solution
|
|
||||||
# Copyright (C) 2014-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 models
|
|
||||||
import controllers
|
|
|
@ -1,17 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
{
|
|
||||||
'name': 'Mass Mailing with CRM',
|
|
||||||
'version': '1.0',
|
|
||||||
'depends': ['mass_mailing', 'crm'],
|
|
||||||
'author': 'OpenERP SA',
|
|
||||||
'category': 'Hidden/Dependency',
|
|
||||||
'description': """
|
|
||||||
Bridge module between Mass Mailing and CRM
|
|
||||||
""",
|
|
||||||
'website': 'http://www.openerp.com',
|
|
||||||
'data': [],
|
|
||||||
'demo': [],
|
|
||||||
'installable': True,
|
|
||||||
'auto_install': True,
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
import main
|
|
|
@ -1,21 +0,0 @@
|
||||||
|
|
||||||
from openerp import http, SUPERUSER_ID
|
|
||||||
from openerp.addons.mass_mailing.controllers import main
|
|
||||||
from openerp.http import request
|
|
||||||
|
|
||||||
|
|
||||||
class MassMailController(main.MassMailController):
|
|
||||||
|
|
||||||
@http.route(['/mail/mailing/<int:mailing_id>/unsubscribe'], type='http', auth='none')
|
|
||||||
def mailing(self, mailing_id, email=None, res_id=None, **post):
|
|
||||||
cr, uid, context = request.cr, request.uid, request.context
|
|
||||||
MassMailing = request.registry['mail.mass_mailing']
|
|
||||||
mailing_ids = MassMailing.exists(cr, SUPERUSER_ID, [mailing_id], context=context)
|
|
||||||
if not mailing_ids:
|
|
||||||
return super(MassMailController, self).mailing(mailing_id, email=email, res_id=res_id, **post)
|
|
||||||
mailing = MassMailing.browse(cr, SUPERUSER_ID, mailing_ids[0], context=context)
|
|
||||||
if mailing.mailing_model == 'crm.lead':
|
|
||||||
record_ids = request.registry[mailing.mailing_model].search(cr, SUPERUSER_ID, [('id', '=', res_id), ('email_from', 'ilike', email)], context=context)
|
|
||||||
request.registry[mailing.mailing_model].write(cr, SUPERUSER_ID, record_ids, {'opt_out': True}, context=context)
|
|
||||||
return 'OK'
|
|
||||||
return super(MassMailController, self).mailing(mailing_id, email=email, res_id=res_id, **post)
|
|
|
@ -1,3 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
import mass_mailing
|
|
|
@ -1,14 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
from openerp.osv import osv
|
|
||||||
|
|
||||||
|
|
||||||
class MassMailing(osv.Model):
|
|
||||||
"""Inherit to add crm.lead objects available for mass mailing """
|
|
||||||
_name = 'mail.mass_mailing'
|
|
||||||
_inherit = 'mail.mass_mailing'
|
|
||||||
|
|
||||||
def _get_mailing_model(self, cr, uid, context=None):
|
|
||||||
res = super(MassMailing, self)._get_mailing_model(cr, uid, context=context)
|
|
||||||
res.append(('crm.lead', 'Leads / Opportunities'))
|
|
||||||
return res
|
|
Loading…
Reference in New Issue