From e5379bc1a050883452fae1e71093467042e9b64d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 11 Jun 2014 10:40:39 +0200 Subject: [PATCH] [IMP] project: task: added reviewer_id field, linking towards a res.users, that is the reviewer of the task. This field is automatically tracked, using a small update of the get_auto_subscribe_fields method that is weirdly implemented. --- addons/hr/hr.py | 4 +++- addons/mail/mail_thread.py | 4 +++- addons/project/project.py | 7 +++++++ addons/project/project_view.xml | 5 +++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/addons/hr/hr.py b/addons/hr/hr.py index 5bb172eb082..85366adfe3b 100644 --- a/addons/hr/hr.py +++ b/addons/hr/hr.py @@ -349,10 +349,12 @@ class hr_employee(osv.osv): else: return super(hr_employee, self).get_suggested_thread(cr, uid, removed_suggested_threads, context) - def _message_get_auto_subscribe_fields(self, cr, uid, updated_fields, auto_follow_fields=['user_id'], context=None): + def _message_get_auto_subscribe_fields(self, cr, uid, updated_fields, auto_follow_fields=None, context=None): """ Overwrite of the original method to always follow user_id field, even when not track_visibility so that a user will follow it's employee """ + if auto_follow_fields is None: + auto_follow_fields = ['user_id'] user_field_lst = [] for name, column_info in self._all_columns.items(): if name in auto_follow_fields and name in updated_fields and column_info.column._obj == 'res.users': diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 55a566880b8..dc2b98fdc93 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -1699,7 +1699,7 @@ class mail_thread(osv.AbstractModel): ], context=context) return fol_obj.unlink(cr, SUPERUSER_ID, fol_ids, context=context) - def _message_get_auto_subscribe_fields(self, cr, uid, updated_fields, auto_follow_fields=['user_id'], context=None): + def _message_get_auto_subscribe_fields(self, cr, uid, updated_fields, auto_follow_fields=None, context=None): """ Returns the list of relational fields linking to res.users that should trigger an auto subscribe. The default list checks for the fields - called 'user_id' @@ -1710,6 +1710,8 @@ class mail_thread(osv.AbstractModel): Override this method if a custom behavior is needed about fields that automatically subscribe users. """ + if auto_follow_fields is None: + auto_follow_fields = ['user_id'] user_field_lst = [] for name, column_info in self._all_columns.items(): if name in auto_follow_fields and name in updated_fields and getattr(column_info.column, 'track_visibility', False) and column_info.column._obj == 'res.users': diff --git a/addons/project/project.py b/addons/project/project.py index d98b9b03e94..a9c487be244 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -782,6 +782,7 @@ class task(osv.osv): 'project.task': (lambda self, cr, uid, ids, c={}: ids, ['work_ids', 'remaining_hours', 'planned_hours'], 10), 'project.task.work': (_get_task, ['hours'], 10), }), + 'reviewer_id': fields.many2one('res.users', 'Reviewer', select=True, track_visibility='onchange'), 'user_id': fields.many2one('res.users', 'Assigned to', select=True, track_visibility='onchange'), 'delegated_user_id': fields.related('child_ids', 'user_id', type='many2one', relation='res.users', string='Delegated To'), 'partner_id': fields.many2one('res.partner', 'Customer'), @@ -801,6 +802,7 @@ class task(osv.osv): 'progress': 0, 'sequence': 10, 'active': True, + 'reviewer_id': lambda obj, cr, uid, ctx=None: uid, 'user_id': lambda obj, cr, uid, ctx=None: uid, 'company_id': lambda self, cr, uid, ctx=None: self.pool.get('res.company')._company_default_get(cr, uid, 'project.task', context=ctx), 'partner_id': lambda self, cr, uid, ctx=None: self._get_default_partner(cr, uid, context=ctx), @@ -1090,6 +1092,11 @@ class task(osv.osv): # Mail gateway # --------------------------------------------------- + def _message_get_auto_subscribe_fields(self, cr, uid, updated_fields, auto_follow_fields=None, context=None): + if auto_follow_fields is None: + auto_follow_fields = ['user_id', 'reviewer_id'] + return super(task, self)._message_get_auto_subscribe_fields(cr, uid, updated_fields, auto_follow_fields, context=context) + def message_get_reply_to(self, cr, uid, ids, context=None): """ Override to get the reply_to of the parent project. """ return [task.project_id.message_get_reply_to()[0] if task.project_id else False diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index b6a839edcf6..693e1b47f13 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -29,9 +29,11 @@ help="Show only tasks having a deadline"/> + + @@ -389,6 +391,9 @@ +