From 407eb9edcb724250643aceca48640e1f7513476c Mon Sep 17 00:00:00 2001
From: Tristan Cavelier <tristan.cavelier@nexedi.com>
Date: Tue, 22 Dec 2015 15:04:09 +0000
Subject: [PATCH] erp5_project: notify assignee only if he has an email address

---
 ...eport_copyOrderPropertiesAndNotifyAssignee.xml | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskReport_copyOrderPropertiesAndNotifyAssignee.xml b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskReport_copyOrderPropertiesAndNotifyAssignee.xml
index 7666e9cead..7df07bb351 100644
--- a/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskReport_copyOrderPropertiesAndNotifyAssignee.xml
+++ b/bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/TaskReport_copyOrderPropertiesAndNotifyAssignee.xml
@@ -85,12 +85,15 @@ destination_decision_person = task_report.getDestinationDecisionValue(portal_typ
 if destination_decision_person is None:\n
   destination_decision_person = task_report.getDestinationValue(portal_type="Person")\n
 \n
-# We send a message only if the requester have an email and the assignee \n
-# is an user that can view the task report.\n
-if source_person is not None \\\n
-     and destination_decision_person is not None \\\n
-     and destination_decision_person.getDefaultEmailText() \\\n
-     and destination_decision_person.getReference():\n
+# We send a message only if the requester has an email\n
+# and the assignee has one too and is an user that can view the task report.\n
+if (\n
+      source_person is not None and\n
+      source_person.getDefaultEmailText() and # XXX Add unit test: check if task confirmation works if assignee has no mail\n
+      destination_decision_person is not None and\n
+      destination_decision_person.getDefaultEmailText() and\n
+      destination_decision_person.getReference()\n
+    ):\n
   if len(portal.acl_users.erp5_users.getUserByLogin(source_person.getReference())):\n
     message = """A new task has been assigned to you by %(assignor)s.\n
 \n
-- 
2.30.9