diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index e0ae94a07da..ba652d9ce48 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -1569,6 +1569,8 @@ class MailThread(models.AbstractModel): # 1: Handle content subtype: if plaintext, converto into HTML if content_subtype == 'plaintext': body = tools.plaintext2html(body) + else: + body = tools.html_keep_url(body) # 2: Private message: add recipients (recipients and author of parent message) - current author # + legacy-code management (! we manage only 4 and 6 commands) diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index 6b42ddc9234..0f8a0223260 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -127,7 +127,7 @@ function add_channel_to_message (message, channel_id) { function post_channel_message (data) { return ChannelModel.call('message_post', [data.channel_id], { message_type: 'comment', - content_subtype: 'plaintext', + content_subtype: 'html', partner_ids: data.partner_ids, body: _.str.trim(data.content), subtype: 'mail.mt_comment', diff --git a/addons/mail/static/src/js/chatter.js b/addons/mail/static/src/js/chatter.js index 8e256377d40..bdee2fe06dc 100644 --- a/addons/mail/static/src/js/chatter.js +++ b/addons/mail/static/src/js/chatter.js @@ -484,7 +484,7 @@ var ChatterComposer = ChatComposer.extend({ subtype_id: false, subtype: 'mail.mt_comment', message_type: 'comment', - content_subtype: 'plaintext', + content_subtype: 'html', }); // Subtype diff --git a/openerp/tools/mail.py b/openerp/tools/mail.py index 09010efe0e7..bfd011fc42c 100644 --- a/openerp/tools/mail.py +++ b/openerp/tools/mail.py @@ -462,6 +462,18 @@ def html_email_clean(html, remove=False, shorten=False, max_length=300, expand_o # HTML/Text management #---------------------------------------------------------- +def html_keep_url(text): + """ Transform the url into clickable link with tag """ + idx = 0 + final = '' + link_tags = re.compile(r'(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?') + for item in re.finditer(link_tags, text): + final += text[idx:item.start()] + final += '%s' % (item.group(0), item.group(0)) + idx = item.end() + final += text[idx:] + return final + def html2plaintext(html, body_id=None, encoding='utf-8'): """ From an HTML text, convert the HTML to plain text. If @param body_id is provided then this is the tag where the @@ -543,15 +555,7 @@ def plaintext2html(text, container_tag=False): text = text.replace('\r', '
') # 2. clickable links - idx = 0 - final = '' - link_tags = re.compile(r'(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?') - for item in re.finditer(link_tags, text): - final += text[idx:item.start()] - final += '%s' % (item.group(0), item.group(0)) - idx = item.end() - final += text[idx:] - text = final + text = html_keep_url(text) # 3-4: form paragraphs idx = 0