[FIX] sale_project: fix the chatter message on fsm product addition

Before this commit, A 'task created' notification is generated
each time the user adds a product from the FSM task even when the
new task is not generated as it's directly linked with particular
fsm task.

So in this commit, check if SOL is linked with the task and if linked then
do not log a message on order chatter.

task-2926348

closes odoo/odoo#103130

X-original-commit: cdf70448b1776b010b6a17f46eb17c7131e6c4b3
Signed-off-by: Laurent Stukkens (ltu) <ltu@odoo.com>
This commit is contained in:
Pallavi Savaliya
2022-10-12 07:35:49 +02:00
committed by Barad Mahendra
parent 754570b1d8
commit 71cdae1c12
@@ -106,9 +106,10 @@ class SaleOrderLine(models.Model):
# generate task with hours=0.
for line in lines:
if line.state == 'sale' and not line.is_expense:
has_task = bool(line.task_id)
line.sudo()._timesheet_service_generation()
# if the SO line created a task, post a message on the order
if line.task_id:
if line.task_id and not has_task:
msg_body = _("Task Created (%s): %s", line.product_id.name, line.task_id._get_html_link())
line.order_id.message_post(body=msg_body)
return lines