[ADD] Added mass_mailing_applicant module, bridge between applicants and mass mailing
bzr revid: tde@openerp.com-20140404150103-pz5kzwspnuk8etn5
This commit is contained in:
parent
08044cd2a2
commit
1f6302d9f4
|
@ -0,0 +1,23 @@
|
|||
# -*- 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
|
|
@ -0,0 +1,19 @@
|
|||
# -*- 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': [
|
||||
'views/hr_applicant.xml',
|
||||
],
|
||||
'demo': [],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
import main
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
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)
|
|
@ -0,0 +1 @@
|
|||
import mass_mailing
|
|
@ -0,0 +1,32 @@
|
|||
# -*- 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
|
||||
|
||||
def _get_model_to_list_action_id(self, cr, uid, model, context=None):
|
||||
if model == 'hr.applicant':
|
||||
return self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'mass_mailing_applicant.action_applicant_to_mailing_list')
|
||||
else:
|
||||
return super(MassMailing, self)._get_model_to_list_action_id(cr, uid, model, context=context)
|
||||
|
||||
def get_recipients_data(self, cr, uid, mailing, res_ids, context=None):
|
||||
if mailing.mailing_model == 'hr.applicant':
|
||||
res = {}
|
||||
for applicant in self.pool['hr.applicant'].browse(cr, uid, res_ids, context=context):
|
||||
if applicant.partner_id:
|
||||
res[applicant.id] = {'partner_id': applicant.partner_id.id, 'name': applicant.partner_id.name, 'email': applicant.partner_id.email}
|
||||
else:
|
||||
name, email = self.pool['res.partner']._parse_partner_name(applicant.email_from, context=context)
|
||||
res[applicant.id] = {'partner_id': False, 'name': name or email, 'email': email}
|
||||
return res
|
||||
return super(MassMailing, self).get_recipients_data(cr, uid, mailing, res_ids, context=context)
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Create a Mailing List from Leads -->
|
||||
<act_window name="Create Mailing List"
|
||||
res_model="mail.mass_mailing.list"
|
||||
src_model="hr.applicant"
|
||||
view_mode="form"
|
||||
multi="True"
|
||||
target="current"
|
||||
key2="client_action_multi"
|
||||
id="action_applicant_to_mailing_list"
|
||||
context="{
|
||||
'default_mass_mailing_id': context.get('default_mass_mailing_id'),
|
||||
'default_model': context.get('default_model', 'hr.applicant'),
|
||||
'default_name': context.get('default_name', False)}"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue