[FIX] project: make custom fields copiable again

Since #73341 copy_data is filtered to avoid leaking information to portal user.
Partically, it makes custom field not copiable.

Fix it by disabling the filter for internal users. This may lead to a problem
with hacky field `personal_stage_type_ids`. To avoid extra complexity in the
code, just mark it as `copy=False`. The latter change is kind of an improvement
from functional point of view, since using default personal stage seems to be a
better idea rather than copying the stage.

---

opw-2746922

closes odoo/odoo#87064

X-original-commit: 9947e82c5c25cde030aca43f7eb6fe1293300329
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
This commit is contained in:
Ivan Yelizariev
2022-03-23 19:25:12 +01:00
parent a5cce9f592
commit 2f1bd13274
+3 -1
View File
@@ -975,7 +975,7 @@ class Task(models.Model):
# Second Many2many containing the actual personal stage for the current user
# See project_task_stage_personal.py for the model defininition
personal_stage_type_ids = fields.Many2many('project.task.type', 'project_task_user_rel', column1='task_id', column2='stage_id',
ondelete='restrict', group_expand='_read_group_personal_stage_type_ids',
ondelete='restrict', group_expand='_read_group_personal_stage_type_ids', copy=False,
domain="[('user_id', '=', user.id)]", depends=['user_ids'], string='Personal Stage')
# Personal Stage computed from the user
personal_stage_id = fields.Many2one('project.task.stage.personal', string='Personal Stage State', compute_sudo=False,
@@ -1655,6 +1655,8 @@ class Task(models.Model):
def copy_data(self, default=None):
defaults = super().copy_data(default=default)
if self.env.user.has_group('project.group_project_user'):
return defaults
return [{k: v for k, v in default.items() if k in self.SELF_READABLE_FIELDS} for default in defaults]
@api.model