[FIX] project: fix default assigned to for rating in task
Before this commit, the default assignee set to a rating in a task is always empty because we check if the `project.task` has a `user_id` field to give the partner of this user. Since it is no longer the case because we can recently assign many users to a task. That is, it is `user_ids` field and no longer `user_id` field. This commit overwrites `rating_get_rated_partner_id` method to set by default the partner of the user contained in `user_ids` field if this field contains at most one user. Otherwise, we set no partner. We choose to not select the first user in the user_ids field because we cannot consider it is the responsible of the task and not another one. We cannot create a rating per user because the rating average will no longer right because at the beginning of the task we could have 5 users and after we could have more users or less users and so the number of ratings for this task could be different each time we send a rating review to the customer. Part of task-2696911 closes odoo/odoo#81009 X-original-commit: 88e7d270bee962d6e4d40f6b62d25a9519abfcf2 Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com> Signed-off-by: Xavier <xbo@odoo.com>
This commit is contained in:
committed by
Xavier BOL (xbo)
parent
060096b872
commit
7ca2c8e6e7
@@ -2190,6 +2190,11 @@ class Task(models.Model):
|
||||
def _rating_get_parent_field_name(self):
|
||||
return 'project_id'
|
||||
|
||||
def rating_get_rated_partner_id(self):
|
||||
""" Overwrite since we have user_ids and not user_id """
|
||||
tasks_with_one_user = self.filtered(lambda task: len(task.user_ids) == 1 and task.user_ids.partner_id)
|
||||
return tasks_with_one_user.user_ids.partner_id or self.env['res.partner']
|
||||
|
||||
# ---------------------------------------------------
|
||||
# Privacy
|
||||
# ---------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user