From 26e3a113df595a9367c904a8144ccafeaf7019ae Mon Sep 17 00:00:00 2001 From: "Thomas Lefebvre (thle)" Date: Tue, 10 Oct 2023 06:56:13 +0000 Subject: [PATCH] [FIX] project: invalidate field to get `user_ids` Steps to reproduce: ------------------- - create a project; - set project visibility of project as 'Invited portal users and all internal users (public)'; - share that project with a portal user; - create a task in that project and set one of user in 'Assignee' of the task; - login in website as that portal user; - from kanban view of task, open a task. Issue: ------ The 'Assignees' are not visible in the opened form view. The `portal_user_name` field will be empty, with the result that no assignees to the task will be displayed in the project task form view. Cause: ------ In the business flow, we first perform a `read` (with portal rights) which will set the value: `project.task.user_ids: {project_id: ()}` in the cache. After, we try to get `user_ids` inside the `_compute_portal_user_names` method. The `insert_missing` method of the cache does not overwrite existing values in cache. Note: fetch method uses `_determine_fields_to_fetch` with parameter `ignore_when_in_cache` equal to `True`. Solution: --------- It is necessary to invalidate the cache for this field for the recordset to make sure the value is updated. opw-3536187 closes odoo/odoo#138557 X-original-commit: e533daf44c7946fae1e4467e70f9363f675dad07 Signed-off-by: Xavier Bol (xbo) Signed-off-by: Thomas Lefebvre (thle) --- addons/project/models/project_task.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/project/models/project_task.py b/addons/project/models/project_task.py index d3cbc192103..c27346b8fa9 100644 --- a/addons/project/models/project_task.py +++ b/addons/project/models/project_task.py @@ -553,6 +553,7 @@ class Task(models.Model): if self._origin: # 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.invalidate_recordset(fnames=['user_ids']) self._origin.fetch(['user_ids']) for task in self.with_context(prefetch_fields=False): task.portal_user_names = ', '.join(task.user_ids.mapped('name'))