[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.
This commit is contained in:
Thibault Delavallée 2014-06-11 10:40:39 +02:00
parent 6981af0221
commit e5379bc1a0
4 changed files with 18 additions and 2 deletions

View File

@ -349,10 +349,12 @@ class hr_employee(osv.osv):
else: else:
return super(hr_employee, self).get_suggested_thread(cr, uid, removed_suggested_threads, context) 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, """ 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 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 = [] user_field_lst = []
for name, column_info in self._all_columns.items(): 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': if name in auto_follow_fields and name in updated_fields and column_info.column._obj == 'res.users':

View File

@ -1699,7 +1699,7 @@ class mail_thread(osv.AbstractModel):
], context=context) ], context=context)
return fol_obj.unlink(cr, SUPERUSER_ID, fol_ids, 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 """ Returns the list of relational fields linking to res.users that should
trigger an auto subscribe. The default list checks for the fields trigger an auto subscribe. The default list checks for the fields
- called 'user_id' - called 'user_id'
@ -1710,6 +1710,8 @@ class mail_thread(osv.AbstractModel):
Override this method if a custom behavior is needed about fields Override this method if a custom behavior is needed about fields
that automatically subscribe users. that automatically subscribe users.
""" """
if auto_follow_fields is None:
auto_follow_fields = ['user_id']
user_field_lst = [] user_field_lst = []
for name, column_info in self._all_columns.items(): 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': 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':

View File

@ -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': (lambda self, cr, uid, ids, c={}: ids, ['work_ids', 'remaining_hours', 'planned_hours'], 10),
'project.task.work': (_get_task, ['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'), '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'), 'delegated_user_id': fields.related('child_ids', 'user_id', type='many2one', relation='res.users', string='Delegated To'),
'partner_id': fields.many2one('res.partner', 'Customer'), 'partner_id': fields.many2one('res.partner', 'Customer'),
@ -801,6 +802,7 @@ class task(osv.osv):
'progress': 0, 'progress': 0,
'sequence': 10, 'sequence': 10,
'active': True, 'active': True,
'reviewer_id': lambda obj, cr, uid, ctx=None: uid,
'user_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), '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), '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 # 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): def message_get_reply_to(self, cr, uid, ids, context=None):
""" Override to get the reply_to of the parent project. """ """ 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 return [task.project_id.message_get_reply_to()[0] if task.project_id else False

View File

@ -29,9 +29,11 @@
help="Show only tasks having a deadline"/> help="Show only tasks having a deadline"/>
<field name="partner_id"/> <field name="partner_id"/>
<field name="project_id"/> <field name="project_id"/>
<field name="reviewer_id"/>
<field name="user_id"/> <field name="user_id"/>
<field name="stage_id" domain="[]"/> <field name="stage_id" domain="[]"/>
<group expand="0" string="Group By..."> <group expand="0" string="Group By...">
<filter string="Reviewers" name="group_reviewer_id" domain="[]" context="{'group_by':'reviewer_id'}"/>
<filter string="Users" name="group_user_id" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/> <filter string="Users" name="group_user_id" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
<filter string="Project" name="group_project_id" icon="terp-folder-violet" domain="[]" context="{'group_by':'project_id'}"/> <filter string="Project" name="group_project_id" icon="terp-folder-violet" domain="[]" context="{'group_by':'project_id'}"/>
<filter string="Stage" name="group_stage_id" icon="terp-stage" domain="[]" context="{'group_by':'stage_id'}"/> <filter string="Stage" name="group_stage_id" icon="terp-stage" domain="[]" context="{'group_by':'stage_id'}"/>
@ -389,6 +391,9 @@
<field name="user_id" <field name="user_id"
options='{"no_open": True}' options='{"no_open": True}'
context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'project.group_project_user']}"/> context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'project.group_project_user']}"/>
<field name="reviewer_id"
options='{"no_open": True}'
context="{'default_groups_ref': ['base.group_user', 'base.group_partner_manager', 'project.group_project_user']}"/>
<field name="planned_hours" widget="float_time" <field name="planned_hours" widget="float_time"
groups="project.group_time_work_estimation_tasks" groups="project.group_time_work_estimation_tasks"
on_change="onchange_planned(planned_hours, effective_hours)"/> on_change="onchange_planned(planned_hours, effective_hours)"/>