diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 6eb5bf50fdb..6c67bc69a2d 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -1451,8 +1451,9 @@ class Task(models.Model): (In other words, this compute is only used in project sharing views to see all assignees for each task) """ if self.ids: - # fetch 'user_ids' in superuser mode (and override value in cache) - self._read(['user_ids']) + # fetch 'user_ids' in superuser mode (and override value in cache + # browse is useful to avoid miscache because of the newIds contained in self + self.browse(self.ids)._read(['user_ids']) for task in self.with_context(prefetch_fields=False): task.portal_user_names = ', '.join(task.user_ids.mapped('name')) diff --git a/addons/project/tests/test_project_sharing.py b/addons/project/tests/test_project_sharing.py index 85a08d6beee..c995cf1d801 100644 --- a/addons/project/tests/test_project_sharing.py +++ b/addons/project/tests/test_project_sharing.py @@ -141,6 +141,7 @@ class TestProjectSharing(TestProjectSharingCommon): 3) Give the 'edit' access mode to a portal user in a project and try to create task with this user. 3.1) Try to change the project of the new task with this user. 3.2) Create a sub-task + 3.3) Create a second sub-task """ # 1) Give the 'read' access mode to a portal user in a project and try to create task with this user. with self.assertRaises(AccessError, msg="Should not accept the portal user create a task in the project when he has not the edit access right."): @@ -190,6 +191,12 @@ class TestProjectSharing(TestProjectSharingCommon): .create({'name': 'Test'}) self.assertFalse(task2.portal_user_names, 'the portal user should not be assigned when the portal user creates a task into the project shared.') + # 3.3) Create a second sub-task + with self.get_project_sharing_form_view(task, self.user_portal) as form: + with form.child_ids.new() as subtask_form: + subtask_form.name = 'Test Subtask' + self.assertEqual(len(task.child_ids), 2, 'Check 2 subtasks has correctly been created by the user portal.') + def test_portal_user_cannot_see_all_assignees(self): """ Test when the portal sees a task he cannot see all the assignees.