[IMP] mail_gateway: display message history timestamp according to user's timezone

bzr revid: odo@openerp.com-20100727152637-yalmhqg6goufxk2x
This commit is contained in:
Olivier Dony
2010-07-27 17:26:37 +02:00
parent 08855162c6
commit a351bbd3d3
+11 -2
View File
@@ -140,19 +140,28 @@ class mailgate_thread(osv.osv):
return True
mailgate_thread()
def format_date_tz(date, tz=None):
if not date:
return 'n/a'
format = tools.DEFAULT_SERVER_DATETIME_FORMAT
return tools.server_to_local_timestamp(date, format, format, tz)
class mailgate_message(osv.osv):
'''
Mailgateway Message
'''
def _get_display_text(self, cr, uid, ids, name, arg, context=None):
if context is None:
context = {}
tz = context.get('tz')
result = {}
for message in self.browse(cr, uid, ids, context=context):
msg_txt = ''
if message.history:
msg_txt += (message.email_from or '/') + ' wrote on ' + message.date + ':\n\t'
msg_txt += (message.email_from or '/') + ' wrote on ' + format_date_tz(message.date, tz) + ':\n\t'
msg_txt += '\n\t'.join(message.description.split('\n')[:3]) + '...'
else:
msg_txt = (message.user_id.name or '/') + ' on ' + message.date + ':\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"
else: