Skip to content
Snippets Groups Projects
Commit 3cc5217f authored by ijas ahammed's avatar ijas ahammed
Browse files

[FIX] link_tracker,test_mail_full: fix traceback while converting links


Currently, when we try to shorten the links from content with help of
`_shorten_links_text` method, it throws traceback if the body(content)
we pass is `False`(might happen when we directly pass a model field of
textual type but the field doesn't have a value yet). It's because
the `re` expects the content to be string / bytestring.

This commit fixes the issue by adding a check in this method, which
will simply return `False` if there's no body.

Task-2628586

closes odoo/odoo#75987

X-original-commit: 41f59a61
Signed-off-by: default avatarThibault Delavallee (tde) <tde@openerp.com>
parent 12559929
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,8 @@ class MailRenderMixin(models.AbstractModel):
:return: updated content
"""
if not content:
return content
base_url = base_url or self.env['ir.config_parameter'].sudo().get_param('web.base.url')
shortened_schema = base_url + '/r/'
unsubscribe_schema = base_url + '/sms/'
......
......@@ -82,6 +82,9 @@ class TestSMSPost(TestMailFullCommon, LinkTrackerMock):
})
link = self.env['link.tracker'].search([('url', '=', link)])
self.assertIn(link.short_url, new_body)
# Bugfix: ensure void content convert does not crash
new_body = self.env['mail.render.mixin']._shorten_links_text(False, self.tracker_values)
self.assertFalse(new_body)
def test_body_link_shorten_wshort(self):
link = 'https://test.odoo.com/r/RAOUL'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment