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 @@
<value> <string>if related_simulation_movement_path_list is None:\n
raise RuntimeError, \'related_simulation_movement_path_list is missing. Update ERP5 Product.\'\n
\n
packing_list = context\n
task_report = context\n
\n
# First, copy Order properties\n
packing_list.PackingList_copyOrderProperties()\n
task_report.PackingList_copyOrderProperties()\n
\n
packing_list = context\n
related_order = packing_list.getCausalityValue()\n
related_order = task_report.getCausalityValue()\n
\n
if packing_list.getSimulationState() == \'draft\':\n
packing_list.edit(\n
if task_report.getSimulationState() == \'draft\':\n
task_report.edit(\n
comment=related_order.getComment(),\n
description = related_order.getDescription(),\n
delivery_mode=related_order.getDeliveryMode(),\n
......@@ -88,21 +87,15 @@ if packing_list.getSimulationState() == \'draft\':\n
)\n
\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
# Notify assignee\n
source_person = context.getSourceValue(portal_type="Person")\n
destination_decision_person = context.getDestinationDecisionValue(portal_type="Person")\n
# Notify the requester.\n
source_person = task_report.getSourceValue(portal_type="Person")\n
destination_decision_person = task_report.getDestinationDecisionValue(portal_type="Person")\n
if destination_decision_person is None:\n
destination_decision_person = context.getDestinationValue(portal_type="Person")\n
if source_person is not None:\n
if destination_decision_person is not None:\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
destination_decision_person = task_report.getDestinationValue(portal_type="Person")\n
if source_person is not None and destination_decision_person is not None:\n
message = """\n
A new task has been assigned to you by %(assignor)s.\n
\n
This task is named: %(title)s\n
......@@ -116,26 +109,29 @@ Stop Date: %(stop_date)s\n
Please wisit ERP5: %(url)s\n
""" % {\n
\'assignor\': destination_decision_person.getTitle(),\n
\'title\' : packing_list.getTitle(),\n
\'url\' : \'%s/%s/view\' % (packing_list.ERP5Site_getAbsoluteUrl(),\n
packing_list.getRelativeUrl()),\n
\'description\' : packing_list.getDescription(),\n
\'start_date\': packing_list.getStartDate().Date(),\n
\'stop_date\': packing_list.getStopDate().Date(),\n
\'title\' : task_report.getTitle(),\n
\'url\' : \'%s/%s/view\' % (task_report.ERP5Site_getAbsoluteUrl(),\n
task_report.getRelativeUrl()),\n
\'description\' : task_report.getDescription(),\n
\'start_date\': task_report.getStartDate().Date(),\n
\'stop_date\': task_report.getStopDate().Date(),\n
}\n
email.activate().send(from_url = from_email,\n
subject="[ERP5 Task] %s" % packing_list.getTitle(), msg = msg)\n
portal = task_report.getPortalObject()\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
# Then, modify state\n
confirm_tag = \'%s_confirm\' % packing_list.getPath()\n
packing_list.activate(after_path_and_method_id=(related_simulation_movement_path_list,\n
confirm_tag = \'%s_confirm\' % task_report.getPath()\n
task_report.activate(after_path_and_method_id=(related_simulation_movement_path_list,\n
(\'immediateReindexObject\',\'recursiveImmediateReindexObject\')),\n
tag=confirm_tag).Delivery_confirm()\n
\n
# First set the packing_list in the building state\n
packing_list.startBuilding()\n
# First set the task_report in the building state\n
task_report.startBuilding()\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
after_tag=confirm_tag).updateCausalityState()\n
</string> </value>
......@@ -190,15 +186,13 @@ packing_list.activate(after_path_and_method_id=(related_simulation_movement_path
<string>None</string>
<string>RuntimeError</string>
<string>context</string>
<string>packing_list</string>
<string>task_report</string>
<string>_getattr_</string>
<string>related_order</string>
<string>source_person</string>
<string>destination_decision_person</string>
<string>from_email</string>
<string>getattr</string>
<string>email</string>
<string>msg</string>
<string>message</string>
<string>portal</string>
<string>confirm_tag</string>
</tuple>
</value>
......
......@@ -67,10 +67,10 @@
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
packing_list = state_change[\'object\']\n
task_report = state_change[\'object\']\n
\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
wf_id=\'task_report_workflow\',\n
default=())\n
......@@ -81,18 +81,13 @@ if len(question_list) > 0:\n
else:\n
question = \'\'\n
\n
\n
\n
# Notify assignee\n
source_person = packing_list.getSourceValue(portal_type="Person")\n
destination_decision_person = packing_list.getDestinationDecisionValue(portal_type="Person")\n
source_person = task_report.getSourceValue(portal_type="Person")\n
destination_decision_person = task_report.getDestinationDecisionValue(portal_type="Person")\n
if destination_decision_person is None:\n
destination_decision_person = packing_list.getDestinationValue(portal_type="Person")\n
if source_person is not None:\n
from_email = destination_decision_person.getDefaultEmailText()\n
email = source_person.getDefaultEmailValue()\n
if email is not None:\n
msg = """\n
destination_decision_person = task_report.getDestinationValue(portal_type="Person")\n
if source_person is not None and destination_decision_person is not None:\n
message = """\n
A question from task has been assigned to you by %(assignor)s.\n
\n
This task is named: %(title)s\n
......@@ -109,15 +104,17 @@ Question:\n
Please visit ERP5: %(url)s\n
""" % {\n
\'assignor\': destination_decision_person.getTitle(),\n
\'title\' : packing_list.getTitle(),\n
\'url\' : \'%s/%s\' % (packing_list.ERP5Site_getAbsoluteUrl(),\n
packing_list.getRelativeUrl()),\n
\'comment\' : packing_list.getComment(),\n
\'start_date\': packing_list.getStartDate().Date(),\n
\'stop_date\': packing_list.getStopDate().Date(),\n
\'title\' : task_report.getTitle(),\n
\'url\' : \'%s/%s\' % (task_report.ERP5Site_getAbsoluteUrl(),\n
task_report.getRelativeUrl()),\n
\'comment\' : task_report.getComment(),\n
\'start_date\': task_report.getStartDate().Date(),\n
\'stop_date\': task_report.getStopDate().Date(),\n
\'question\' : question,\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>
......@@ -164,7 +161,7 @@ Please visit ERP5: %(url)s\n
<tuple>
<string>state_change</string>
<string>_getitem_</string>
<string>packing_list</string>
<string>task_report</string>
<string>_getattr_</string>
<string>context</string>
<string>history</string>
......@@ -177,9 +174,8 @@ Please visit ERP5: %(url)s\n
<string>source_person</string>
<string>destination_decision_person</string>
<string>None</string>
<string>from_email</string>
<string>email</string>
<string>msg</string>
<string>message</string>
<string>portal</string>
</tuple>
</value>
</item>
......
......@@ -65,18 +65,15 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>packing_list = state_change[\'object\']\n
<value> <string>task_report = state_change[\'object\']\n
\n
# Notify assignee\n
source_person = packing_list.getSourceValue(portal_type="Person")\n
destination_decision_person = packing_list.getDestinationDecisionValue(portal_type="Person")\n
source_person = task_report.getSourceValue(portal_type="Person")\n
destination_decision_person = task_report.getDestinationDecisionValue(portal_type="Person")\n
if destination_decision_person is None:\n
destination_decision_person = packing_list.getDestinationValue(portal_type="Person")\n
if source_person is not None:\n
from_email = destination_decision_person.getDefaultEmailText()\n
email = source_person.getDefaultEmailValue()\n
if email is not None:\n
msg = """\n
destination_decision_person = task_report.getDestinationValue(portal_type="Person")\n
if source_person is not None and destination_decision_person is not None:\n
message = """\n
Restarted task has been assigned to you by %(assignor)s.\n
\n
This task is named: %(title)s\n
......@@ -90,14 +87,16 @@ Stop Date: %(stop_date)s\n
Please visit ERP5: %(url)s\n
""" % {\n
\'assignor\': destination_decision_person.getTitle(),\n
\'title\' : packing_list.getTitle(),\n
\'url\' : \'%s/%s\' % (packing_list.ERP5Site_getAbsoluteUrl(),\n
packing_list.getRelativeUrl()),\n
\'comment\' : packing_list.getComment(),\n
\'start_date\': packing_list.getStartDate().Date(),\n
\'stop_date\': packing_list.getStopDate().Date(),\n
\'title\' : task_report.getTitle(),\n
\'url\' : \'%s/%s\' % (task_report.ERP5Site_getAbsoluteUrl(),\n
task_report.getRelativeUrl()),\n
\'comment\' : task_report.getComment(),\n
\'start_date\': task_report.getStartDate().Date(),\n
\'stop_date\': task_report.getStopDate().Date(),\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>
</item>
<item>
......@@ -142,14 +141,13 @@ Please visit ERP5: %(url)s\n
<tuple>
<string>state_change</string>
<string>_getitem_</string>
<string>packing_list</string>
<string>task_report</string>
<string>_getattr_</string>
<string>source_person</string>
<string>destination_decision_person</string>
<string>None</string>
<string>from_email</string>
<string>email</string>
<string>msg</string>
<string>message</string>
<string>portal</string>
</tuple>
</value>
</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