diff options
| author | qho <qho@odoo.com> | 2020-03-10 07:50:27 +0000 |
|---|---|---|
| committer | Yannick Tivisse <yti@odoo.com> | 2020-06-29 11:56:36 +0000 |
| commit | 1424a3839a6c304599bdeefcd74f29279ae75420 (patch) | |
| tree | f78d9388f3dfd55ffdc8b24ac6aaa4304571fd94 /addons/project/models | |
| parent | 78e2d2e2fb49814c2f51dd97d2ddba6ba533d2e1 (diff) | |
[IMP] hr_timesheet: Improve the usability of timesheet portal
1. Generic timesheets improvements
- Portal /my/timesheets
- Add a group bys task, date, employee
- Add search in project, name, employee, task
* The task column should not be visible if none of the timesheets have the Task field set
- If a group by task, date, employee or project is applied, the corresponding column should not be visible
2. Timesheets from sub-tasks on parent tasks
- Portal /my/tasks
- Display the 'Total Hours' spent on a task at the end of the list of timesheets
- Below the list of timesheets for the task, display another table detailing the respective timesheets (and total hours) of each sub-task linked to this task (= 1 table/list per sub-task)
* Title should be: 'Timesheets for sub-task: xyz'
* only visible if there are sub-tasks linked to this task
* only visible if total hours > 0
3. Timesheets on Invoices
- Portal /my/invoices
- Add Project + task fields
* Task field only visible if set on one of the timesheet entries
* Project field only visible if there are at least 2 different projects in these timesheet entries
4. Correct visibility for the portal users
- Portal users is allowed to see timesheets if the users are added in allowed portal users list in the project
- When a portal user is added as the message follower of the project, the user is added to allowed portal users as well
- When a portal user is removed from allowed portal users, the user is also removed from message followers
closes odoo/odoo#47248
Taskid: 2201908
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/project/models')
| -rw-r--r-- | addons/project/models/project.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 4ab3f1380b3..498aa9a96f3 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -341,6 +341,8 @@ class Project(models.Model): if allowed_users_changed: for project in self: permission_removed = allowed_users.get(project) - project.allowed_user_ids + allowed_portal_users_removed = permission_removed.filtered('share') + project.message_unsubscribe(allowed_portal_users_removed.partner_id.commercial_partner_id.ids) for task in project.task_ids: task.allowed_user_ids -= permission_removed @@ -384,13 +386,18 @@ class Project(models.Model): return result def message_subscribe(self, partner_ids=None, channel_ids=None, subtype_ids=None): - """ Subscribe to all existing active tasks when subscribing to a project """ + """ + Subscribe to all existing active tasks when subscribing to a project + And add the portal user subscribed to allowed portal users + """ res = super(Project, self).message_subscribe(partner_ids=partner_ids, channel_ids=channel_ids, subtype_ids=subtype_ids) project_subtypes = self.env['mail.message.subtype'].browse(subtype_ids) if subtype_ids else None task_subtypes = project_subtypes.mapped('parent_id').ids if project_subtypes else None if not subtype_ids or task_subtypes: self.mapped('tasks').message_subscribe( partner_ids=partner_ids, channel_ids=channel_ids, subtype_ids=task_subtypes) + if partner_ids: + self.allowed_portal_user_ids |= self.env['res.partner'].browse(partner_ids).user_ids.filtered('share') return res def message_unsubscribe(self, partner_ids=None, channel_ids=None): @@ -780,6 +787,17 @@ class Task(models.Model): ) return super(Task, self).get_empty_list_help(help) + def message_subscribe(self, partner_ids=None, channel_ids=None, subtype_ids=None): + """ + Add the users subscribed to allowed portal users + """ + res = super(Task, self).message_subscribe(partner_ids=partner_ids, channel_ids=channel_ids, subtype_ids=subtype_ids) + if partner_ids: + new_allowed_users = self.env['res.partner'].browse(partner_ids).user_ids.filtered('share') + tasks = self.filtered(lambda task: task.project_id.privacy_visibility == 'portal') + tasks.write({'allowed_user_ids': [(4, user.id) for user in new_allowed_users]}) + return res + # ---------------------------------------- # Case management # ---------------------------------------- |
