Commit 0a012748 authored by Rafael Monnerat's avatar Rafael Monnerat

Improved Notification Messages and scripts. Use portal_notifications instead email.send() .

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21516 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 32655a42
...@@ -68,16 +68,15 @@ ...@@ -68,16 +68,15 @@
<value> <string>if related_simulation_movement_path_list is None:\n <value> <string>if related_simulation_movement_path_list is None:\n
raise RuntimeError, \'related_simulation_movement_path_list is missing. Update ERP5 Product.\'\n raise RuntimeError, \'related_simulation_movement_path_list is missing. Update ERP5 Product.\'\n
\n \n
packing_list = context\n task_report = context\n
\n \n
# First, copy Order properties\n # First, copy Order properties\n
packing_list.PackingList_copyOrderProperties()\n task_report.PackingList_copyOrderProperties()\n
\n \n
packing_list = context\n related_order = task_report.getCausalityValue()\n
related_order = packing_list.getCausalityValue()\n
\n \n
if packing_list.getSimulationState() == \'draft\':\n if task_report.getSimulationState() == \'draft\':\n
packing_list.edit(\n task_report.edit(\n
comment=related_order.getComment(),\n comment=related_order.getComment(),\n
description = related_order.getDescription(),\n description = related_order.getDescription(),\n
delivery_mode=related_order.getDeliveryMode(),\n delivery_mode=related_order.getDeliveryMode(),\n
...@@ -88,21 +87,15 @@ if packing_list.getSimulationState() == \'draft\':\n ...@@ -88,21 +87,15 @@ if packing_list.getSimulationState() == \'draft\':\n
)\n )\n
\n \n
# If security definitions are implemented on the packing list, it is time to apply them\n # If security definitions are implemented on the packing list, it is time to apply them\n
packing_list.assignRoleToSecurityGroup()\n task_report.assignRoleToSecurityGroup()\n
\n \n
# Notify assignee\n # Notify the requester.\n
source_person = context.getSourceValue(portal_type="Person")\n source_person = task_report.getSourceValue(portal_type="Person")\n
destination_decision_person = context.getDestinationDecisionValue(portal_type="Person")\n destination_decision_person = task_report.getDestinationDecisionValue(portal_type="Person")\n
if destination_decision_person is None:\n if destination_decision_person is None:\n
destination_decision_person = context.getDestinationValue(portal_type="Person")\n destination_decision_person = task_report.getDestinationValue(portal_type="Person")\n
if source_person is not None:\n if source_person is not None and destination_decision_person is not None:\n
if destination_decision_person is not None:\n message = """\n
from_email = destination_decision_person.getDefaultEmailText()\n
else:\n
from_email = getattr(context, \'email_from_address\', None)\n
email = source_person.getDefaultEmailValue()\n
if email is not None:\n
msg = """\n
A new task has been assigned to you by %(assignor)s.\n A new task has been assigned to you by %(assignor)s.\n
\n \n
This task is named: %(title)s\n This task is named: %(title)s\n
...@@ -116,26 +109,29 @@ Stop Date: %(stop_date)s\n ...@@ -116,26 +109,29 @@ Stop Date: %(stop_date)s\n
Please wisit ERP5: %(url)s\n Please wisit ERP5: %(url)s\n
""" % {\n """ % {\n
\'assignor\': destination_decision_person.getTitle(),\n \'assignor\': destination_decision_person.getTitle(),\n
\'title\' : packing_list.getTitle(),\n \'title\' : task_report.getTitle(),\n
\'url\' : \'%s/%s/view\' % (packing_list.ERP5Site_getAbsoluteUrl(),\n \'url\' : \'%s/%s/view\' % (task_report.ERP5Site_getAbsoluteUrl(),\n
packing_list.getRelativeUrl()),\n task_report.getRelativeUrl()),\n
\'description\' : packing_list.getDescription(),\n \'description\' : task_report.getDescription(),\n
\'start_date\': packing_list.getStartDate().Date(),\n \'start_date\': task_report.getStartDate().Date(),\n
\'stop_date\': packing_list.getStopDate().Date(),\n \'stop_date\': task_report.getStopDate().Date(),\n
}\n }\n
email.activate().send(from_url = from_email,\n portal = task_report.getPortalObject()\n
subject="[ERP5 Task] %s" % packing_list.getTitle(), msg = msg)\n portal.portal_notifications.sendMessage(sender=destination_decision_person,\n
recipient=source_person, \n
subject="[ERP5 Task] %s" % task_report.getTitle(), \n
message=message)\n
\n \n
# Then, modify state\n # Then, modify state\n
confirm_tag = \'%s_confirm\' % packing_list.getPath()\n confirm_tag = \'%s_confirm\' % task_report.getPath()\n
packing_list.activate(after_path_and_method_id=(related_simulation_movement_path_list,\n task_report.activate(after_path_and_method_id=(related_simulation_movement_path_list,\n
(\'immediateReindexObject\',\'recursiveImmediateReindexObject\')),\n (\'immediateReindexObject\',\'recursiveImmediateReindexObject\')),\n
tag=confirm_tag).Delivery_confirm()\n tag=confirm_tag).Delivery_confirm()\n
\n \n
# First set the packing_list in the building state\n # First set the task_report in the building state\n
packing_list.startBuilding()\n task_report.startBuilding()\n
# Then an activity should put the causality state in diverged or solved\n # Then an activity should put the causality state in diverged or solved\n
packing_list.activate(after_path_and_method_id=(related_simulation_movement_path_list,\n task_report.activate(after_path_and_method_id=(related_simulation_movement_path_list,\n
(\'immediateReindexObject\',\'recursiveImmediateReindexObject\')),\n (\'immediateReindexObject\',\'recursiveImmediateReindexObject\')),\n
after_tag=confirm_tag).updateCausalityState()\n after_tag=confirm_tag).updateCausalityState()\n
</string> </value> </string> </value>
...@@ -190,15 +186,13 @@ packing_list.activate(after_path_and_method_id=(related_simulation_movement_path ...@@ -190,15 +186,13 @@ packing_list.activate(after_path_and_method_id=(related_simulation_movement_path
<string>None</string> <string>None</string>
<string>RuntimeError</string> <string>RuntimeError</string>
<string>context</string> <string>context</string>
<string>packing_list</string> <string>task_report</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>related_order</string> <string>related_order</string>
<string>source_person</string> <string>source_person</string>
<string>destination_decision_person</string> <string>destination_decision_person</string>
<string>from_email</string> <string>message</string>
<string>getattr</string> <string>portal</string>
<string>email</string>
<string>msg</string>
<string>confirm_tag</string> <string>confirm_tag</string>
</tuple> </tuple>
</value> </value>
......
...@@ -67,10 +67,10 @@ ...@@ -67,10 +67,10 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
packing_list = state_change[\'object\']\n task_report = state_change[\'object\']\n
\n \n
# get question\n # get question\n
history = context.portal_workflow.getInfoFor(ob=packing_list,\n history = context.portal_workflow.getInfoFor(ob=task_report,\n
name=\'history\',\n name=\'history\',\n
wf_id=\'task_report_workflow\',\n wf_id=\'task_report_workflow\',\n
default=())\n default=())\n
...@@ -81,18 +81,13 @@ if len(question_list) > 0:\n ...@@ -81,18 +81,13 @@ if len(question_list) > 0:\n
else:\n else:\n
question = \'\'\n question = \'\'\n
\n \n
\n
\n
# Notify assignee\n # Notify assignee\n
source_person = packing_list.getSourceValue(portal_type="Person")\n source_person = task_report.getSourceValue(portal_type="Person")\n
destination_decision_person = packing_list.getDestinationDecisionValue(portal_type="Person")\n destination_decision_person = task_report.getDestinationDecisionValue(portal_type="Person")\n
if destination_decision_person is None:\n if destination_decision_person is None:\n
destination_decision_person = packing_list.getDestinationValue(portal_type="Person")\n destination_decision_person = task_report.getDestinationValue(portal_type="Person")\n
if source_person is not None:\n if source_person is not None and destination_decision_person is not None:\n
from_email = destination_decision_person.getDefaultEmailText()\n message = """\n
email = source_person.getDefaultEmailValue()\n
if email is not None:\n
msg = """\n
A question from task has been assigned to you by %(assignor)s.\n A question from task has been assigned to you by %(assignor)s.\n
\n \n
This task is named: %(title)s\n This task is named: %(title)s\n
...@@ -109,15 +104,17 @@ Question:\n ...@@ -109,15 +104,17 @@ Question:\n
Please visit ERP5: %(url)s\n Please visit ERP5: %(url)s\n
""" % {\n """ % {\n
\'assignor\': destination_decision_person.getTitle(),\n \'assignor\': destination_decision_person.getTitle(),\n
\'title\' : packing_list.getTitle(),\n \'title\' : task_report.getTitle(),\n
\'url\' : \'%s/%s\' % (packing_list.ERP5Site_getAbsoluteUrl(),\n \'url\' : \'%s/%s\' % (task_report.ERP5Site_getAbsoluteUrl(),\n
packing_list.getRelativeUrl()),\n task_report.getRelativeUrl()),\n
\'comment\' : packing_list.getComment(),\n \'comment\' : task_report.getComment(),\n
\'start_date\': packing_list.getStartDate().Date(),\n \'start_date\': task_report.getStartDate().Date(),\n
\'stop_date\': packing_list.getStopDate().Date(),\n \'stop_date\': task_report.getStopDate().Date(),\n
\'question\' : question,\n \'question\' : question,\n
}\n }\n
email.activate().send(from_url = from_email, subject=" Task Assigned to You", msg = msg)\n portal = task_report.getPortalObject()\n
portal.portal_notifications.sendMessage(sender=destination_decision_person, recipient=source_person,\n
subject="[ERP5 Task] Question to You", message=message)\n
]]></string> </value> ]]></string> </value>
...@@ -164,7 +161,7 @@ Please visit ERP5: %(url)s\n ...@@ -164,7 +161,7 @@ Please visit ERP5: %(url)s\n
<tuple> <tuple>
<string>state_change</string> <string>state_change</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>packing_list</string> <string>task_report</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>history</string> <string>history</string>
...@@ -177,9 +174,8 @@ Please visit ERP5: %(url)s\n ...@@ -177,9 +174,8 @@ Please visit ERP5: %(url)s\n
<string>source_person</string> <string>source_person</string>
<string>destination_decision_person</string> <string>destination_decision_person</string>
<string>None</string> <string>None</string>
<string>from_email</string> <string>message</string>
<string>email</string> <string>portal</string>
<string>msg</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -65,18 +65,15 @@ ...@@ -65,18 +65,15 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>packing_list = state_change[\'object\']\n <value> <string>task_report = state_change[\'object\']\n
\n \n
# Notify assignee\n # Notify assignee\n
source_person = packing_list.getSourceValue(portal_type="Person")\n source_person = task_report.getSourceValue(portal_type="Person")\n
destination_decision_person = packing_list.getDestinationDecisionValue(portal_type="Person")\n destination_decision_person = task_report.getDestinationDecisionValue(portal_type="Person")\n
if destination_decision_person is None:\n if destination_decision_person is None:\n
destination_decision_person = packing_list.getDestinationValue(portal_type="Person")\n destination_decision_person = task_report.getDestinationValue(portal_type="Person")\n
if source_person is not None:\n if source_person is not None and destination_decision_person is not None:\n
from_email = destination_decision_person.getDefaultEmailText()\n message = """\n
email = source_person.getDefaultEmailValue()\n
if email is not None:\n
msg = """\n
Restarted task has been assigned to you by %(assignor)s.\n Restarted task has been assigned to you by %(assignor)s.\n
\n \n
This task is named: %(title)s\n This task is named: %(title)s\n
...@@ -90,14 +87,16 @@ Stop Date: %(stop_date)s\n ...@@ -90,14 +87,16 @@ Stop Date: %(stop_date)s\n
Please visit ERP5: %(url)s\n Please visit ERP5: %(url)s\n
""" % {\n """ % {\n
\'assignor\': destination_decision_person.getTitle(),\n \'assignor\': destination_decision_person.getTitle(),\n
\'title\' : packing_list.getTitle(),\n \'title\' : task_report.getTitle(),\n
\'url\' : \'%s/%s\' % (packing_list.ERP5Site_getAbsoluteUrl(),\n \'url\' : \'%s/%s\' % (task_report.ERP5Site_getAbsoluteUrl(),\n
packing_list.getRelativeUrl()),\n task_report.getRelativeUrl()),\n
\'comment\' : packing_list.getComment(),\n \'comment\' : task_report.getComment(),\n
\'start_date\': packing_list.getStartDate().Date(),\n \'start_date\': task_report.getStartDate().Date(),\n
\'stop_date\': packing_list.getStopDate().Date(),\n \'stop_date\': task_report.getStopDate().Date(),\n
}\n }\n
email.activate().send(from_url = from_email, subject="Restarted Task Assigned to You", msg = msg)\n portal = task_report.getPortalObject()\n
portal.portal_notifications.sendMessage(sender=destination_decision_person, recipient=source_person,\n
subject="[ERP5 Task] Restarted Task Assigned to You ", message=message)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -142,14 +141,13 @@ Please visit ERP5: %(url)s\n ...@@ -142,14 +141,13 @@ Please visit ERP5: %(url)s\n
<tuple> <tuple>
<string>state_change</string> <string>state_change</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>packing_list</string> <string>task_report</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>source_person</string> <string>source_person</string>
<string>destination_decision_person</string> <string>destination_decision_person</string>
<string>None</string> <string>None</string>
<string>from_email</string> <string>message</string>
<string>email</string> <string>portal</string>
<string>msg</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment