[FIX] project: Fix wrong recipient display based on email_from

Currently, The customer that is not selected anymore is suggested
as a recipient

steps to reproduce:
1. create a project task without a customer set
2. select a customer, then remove it, then save
3. send a message in the chatter
--> the customer that is not selected anymore is still suggested as
a recipient.
The issue is due to invalid value of partner's email in the field
email_from on task.

So in this commit, when the customer is not defined or is not a child
task then keep the email_From of the task.
(Here we are checking the task.parent_id because when someone update
the email_from on parent it should be updated in child task's
email_from and when we remove the email_From in parent it should not
be removed from child task)

closes odoo/odoo#63055

Taskid: 2339894
X-original-commit: 46fd7d7979f25c5fe8fe36999186a10ffb6376dc
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
Kamesh Patel
2020-12-08 17:13:53 +00:00
committed by Yannick Tivisse
parent ec65813040
commit 9a18bb89fe
+1 -1
View File
@@ -1172,7 +1172,7 @@ class Task(models.Model):
@api.depends('partner_id.email', 'parent_id.email_from')
def _compute_email_from(self):
for task in self:
task.email_from = task.partner_id.email or task.email_from or task.parent_id.email_from
task.email_from = task.partner_id.email or ((task.partner_id or task.parent_id) and task.email_from) or task.parent_id.email_from
@api.depends('parent_id.project_id.subtask_project_id')
def _compute_project_id(self):