From 12e1e6ad795e5af4835302f25de114abe6f607dc Mon Sep 17 00:00:00 2001 From: Chris Biersbach Date: Tue, 12 Mar 2013 13:24:28 +0100 Subject: [PATCH] [IMP] Project Issue: Replaces the old message_ids based detection of new messages by an override of mail_thread message_post. The date of last action will be updated to the current date on each message_post call. bzr revid: cbi@openerp.com-20130312122428-9s21kgtac8u3lyaf --- addons/project_issue/project_issue.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 9233a95634c..eab505443c3 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -393,7 +393,7 @@ class project_issue(base_stage, osv.osv): def write(self, cr, uid, ids, vals, context=None): #Update last action date every time the user change the stage, the state or send a new email - logged_fields = ['stage_id', 'state', 'message_ids'] + logged_fields = ['stage_id', 'state'] if any([field in vals for field in logged_fields]): vals['date_action_last'] = time.strftime('%Y-%m-%d %H:%M:%S') @@ -545,6 +545,14 @@ class project_issue(base_stage, osv.osv): return super(project_issue, self).message_update(cr, uid, ids, msg, update_vals=update_vals, context=context) + def message_post(self, cr, uid, thread_id, body='', subject=None, type='notification', subtype=None, parent_id=False, attachments=None, context=None, content_subtype='html', **kwargs): + """ Overrides mail_thread message_post so that we can set the date of last action field when + a new message is posted on the issue. + """ + if thread_id: + self.write(cr, uid, thread_id, {'date_action_last': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context) + + return super(project_issue, self).message_post(cr, uid, thread_id, body=body, subject=subject, type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=context, content_subtype=content_subtype, **kwargs) class project(osv.osv): _inherit = "project.project"