groupeurd_newsletter v0.4: fix unsubscribe on send all
This commit is contained in:
parent
9f8e3f5893
commit
21aee8638b
@ -31,7 +31,7 @@
|
|||||||
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
|
# Check https://github.com/odoo/odoo/blob/master/openerp/addons/base/module/module_data.xml
|
||||||
# for the full list
|
# for the full list
|
||||||
'category': 'Marketing',
|
'category': 'Marketing',
|
||||||
'version': '0.3',
|
'version': '0.4',
|
||||||
|
|
||||||
# any module necessary for this one to work correctly
|
# any module necessary for this one to work correctly
|
||||||
'depends': ['base','mass_mailing','marketing','website_mail'],
|
'depends': ['base','mass_mailing','marketing','website_mail'],
|
||||||
|
@ -41,7 +41,10 @@ class MailMail(osv.Model):
|
|||||||
_inherit = ['mail.mail']
|
_inherit = ['mail.mail']
|
||||||
|
|
||||||
def _get_unsubscribe_url(self, cr, uid, mail, email_to, msg=None, context=None):
|
def _get_unsubscribe_url(self, cr, uid, mail, email_to, msg=None, context=None):
|
||||||
|
if 'mass_mailing_test' in context:
|
||||||
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
|
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
|
||||||
|
else:
|
||||||
|
base_url = ""
|
||||||
url = urlparse.urljoin(
|
url = urlparse.urljoin(
|
||||||
base_url, 'mail/mailing/%(mailing_id)s/unsubscribe?%(params)s' % {
|
base_url, 'mail/mailing/%(mailing_id)s/unsubscribe?%(params)s' % {
|
||||||
'mailing_id': mail.mailing_id.id,
|
'mailing_id': mail.mailing_id.id,
|
||||||
@ -51,12 +54,14 @@ class MailMail(osv.Model):
|
|||||||
return '%s' % url
|
return '%s' % url
|
||||||
|
|
||||||
def _get_html_version_url(self, cr, uid, mail, email_to, context=None):
|
def _get_html_version_url(self, cr, uid, mail, email_to, context=None):
|
||||||
|
if 'mass_mailing_test' in context:
|
||||||
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
|
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url')
|
||||||
|
else:
|
||||||
|
base_url = ""
|
||||||
url = urlparse.urljoin(base_url, 'newsletter/html_version_%s' % mail.mailing_id.id)
|
url = urlparse.urljoin(base_url, 'newsletter/html_version_%s' % mail.mailing_id.id)
|
||||||
return '%s' % url
|
return '%s' % url
|
||||||
|
|
||||||
def send_get_email_dict(self, cr, uid, mail, partner=None, context=None):
|
def send_get_email_dict(self, cr, uid, mail, partner=None, context=None):
|
||||||
|
|
||||||
email_to = self.send_get_mail_to(cr, uid, mail, partner=partner, context=context)
|
email_to = self.send_get_mail_to(cr, uid, mail, partner=partner, context=context)
|
||||||
body = self.send_get_mail_body(cr, uid, mail, partner=partner, context=context)
|
body = self.send_get_mail_body(cr, uid, mail, partner=partner, context=context)
|
||||||
|
|
||||||
@ -90,6 +95,9 @@ class TestMassMailing(osv.TransientModel):
|
|||||||
mass_mailing_id = fields.Many2one('mail.mass_mailing', 'Mailing', required=True, ondelete='cascade')
|
mass_mailing_id = fields.Many2one('mail.mass_mailing', 'Mailing', required=True, ondelete='cascade')
|
||||||
|
|
||||||
def send_mail_test(self, cr, uid, ids, context=None):
|
def send_mail_test(self, cr, uid, ids, context=None):
|
||||||
|
#Add a 'mass_mailing_test' flag in the context to be able to build correct HTML_VERSION/UNSUBSCRIBE URLs in test mode
|
||||||
|
context['mass_mailing_test'] = True
|
||||||
|
|
||||||
Mail = self.pool['mail.mail']
|
Mail = self.pool['mail.mail']
|
||||||
for wizard in self.browse(cr, uid, ids, context=context):
|
for wizard in self.browse(cr, uid, ids, context=context):
|
||||||
mailing = wizard.mass_mailing_id
|
mailing = wizard.mass_mailing_id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user