[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) <xbo@odoo.com>
Signed-off-by: Thomas Lefebvre (thle) <thle@odoo.com>
This commit is contained in:
@@ -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'))
|
||||
|
||||
Reference in New Issue
Block a user