From 81cd29fff9dda5ffb03b3e931be2d853b7f2d8bb Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Thu, 9 Sep 2010 17:10:21 +0530 Subject: [PATCH] [FIX]: mail_gateway: Removed unnecessary truncation of communication history message lp bug: https://launchpad.net/bugs/628719 fixed bzr revid: rpa@tinyerp.com-20100909114021-y7w72lhlr1sl13kl --- addons/mail_gateway/mail_gateway.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/mail_gateway/mail_gateway.py b/addons/mail_gateway/mail_gateway.py index 350c9f70092..3a40aac2649 100644 --- a/addons/mail_gateway/mail_gateway.py +++ b/addons/mail_gateway/mail_gateway.py @@ -176,6 +176,14 @@ class mailgate_message(osv.osv): ''' Mailgateway Message ''' + def truncate_data(self, cr, uid, data, context=None): + data_list = data and data.split('\n') or [] + if len(data_list) > 3: + res = '\n\t'.join(data_list[:3]) + '...' + else: + res = '\n\t'.join(data_list) + return res + def _get_display_text(self, cr, uid, ids, name, arg, context=None): if context is None: context = {} @@ -186,11 +194,14 @@ class mailgate_message(osv.osv): if message.history: msg_txt += (message.email_from or '/') + _(' wrote on ') + format_date_tz(message.date, tz) + ':\n\t' if message.description: - msg_txt += '\n\t'.join(message.description.split('\n')[:3]) + '...' + msg_txt += self.truncate_data(cr, uid, message.description, context=context) else: - msg_txt = (message.user_id.name or '/') + _(' on ') + format_date_tz(message.date, tz) + ':\n\t' + msg_txt = (message.user_id.name or '/') + _(' on ') + format_date_tz(message.date, tz) + ':\n\t' if message.name == _('Opportunity'): msg_txt += _("Converted to Opportunity") + elif message.name == _('Note'): + msg_txt = (message.user_id.name or '/') + _(' added note on ') + format_date_tz(message.date, tz) + ':\n\t' + msg_txt += self.truncate_data(cr, uid, message.description, context=context) else: msg_txt += _("Changed Status to: ") + message.name result[message.id] = msg_txt