Commit fa095872 authored by Łukasz Nowak's avatar Łukasz Nowak

- added Adopt action, by coping quantity from simulation

- proper case of Split & Defer

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22382 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 80c838ed
...@@ -76,12 +76,26 @@ tag = context.getPath() + \'_split\'\n ...@@ -76,12 +76,26 @@ tag = context.getPath() + \'_split\'\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
packing_list_portal_type = context.getPortalType()\n packing_list_portal_type = context.getPortalType()\n
\n \n
simulation_tool = portal.portal_simulation\n
\n
split_and_defer = 0\n split_and_defer = 0\n
\n \n
packing_list_portal_type_delivery_builder_mapping = {\n packing_list_portal_type_delivery_builder_mapping = {\n
\'Production Packing List\' : \'production_packing_list_builder\',\n \'Production Packing List\' : \'production_packing_list_builder\',\n
\'Production Report\' : \'production_report_builder\',\n \'Production Report\' : \'production_report_builder\',\n
}\n }\n
order = context.getCausalityValue()\n
applied_rule = order.getCausalityRelatedValue(portal_type="Applied Rule")\n
\n
builder_id = packing_list_portal_type_delivery_builder_mapping.get(\n
packing_list_portal_type, None)\n
if builder_id is not None:\n
delivery_builder = getattr(portal.portal_deliveries,builder_id,None)\n
if delivery_builder is None:\n
log(\'ProductionPackingList_doSolveActions\',\'Builder %s not found\'%(builder_id,),200)\n
\n
else:\n
log(\'ProductionPackingList_doSolveActions\',\'Portal type %s has no builder\'%(packing_list_portal_type,),200)\n
\n \n
if listbox is not None:\n if listbox is not None:\n
context.updateAppliedRule()\n context.updateAppliedRule()\n
...@@ -90,36 +104,25 @@ if listbox is not None:\n ...@@ -90,36 +104,25 @@ if listbox is not None:\n
url = line[\'listbox_key\']\n url = line[\'listbox_key\']\n
quantity = line[\'quantity\']\n quantity = line[\'quantity\']\n
movement = context.restrictedTraverse(url)\n movement = context.restrictedTraverse(url)\n
movement.setProperty(\'quantity\', quantity, type=\'float\')\n
choice = line[\'choice\'] \n choice = line[\'choice\'] \n
if choice == \'SplitAndDefer\':\n if choice == \'SplitAndDefer\':\n
movement.setProperty(\'quantity\', quantity, type=\'float\')\n
split_and_defer = 1\n split_and_defer = 1\n
context.portal_simulation.solveMovement(movement, None, "SplitAndDefer", start_date=start_date, stop_date=stop_date, activate_kw={\'tag\':tag})\n simulation_tool.solveMovement(movement, None, "SplitAndDefer", start_date=start_date, stop_date=stop_date, activate_kw={\'tag\':tag})\n
elif choice == \'CopyToTarget\':\n elif choice == \'CopyToTarget\':\n
context.portal_simulation.solveMovement(movement, None,"CopyToTarget")\n movement.setProperty(\'quantity\', quantity, type=\'float\')\n
#elif XXX: support for adopt\n simulation_tool.solveMovement(movement, None,"CopyToTarget")\n
elif choice == \'AdoptPrevision\':\n
prevision_quantity = sum([x.getQuantity() for x in movement.getDeliveryRelatedValueList()])\n
movement.setProperty(\'quantity\', prevision_quantity, type=\'float\')\n
\n \n
context.updateCausalityState()\n context.activate().updateCausalityState()\n
\n \n
if split_and_defer:\n if split_and_defer:\n
# Create delivery\n # Create delivery\n
order = context.getCausalityValue()\n
applied_rule = order.getCausalityRelatedValue(portal_type="Applied Rule")\n
\n
builder_id = packing_list_portal_type_delivery_builder_mapping.get(\n
packing_list_portal_type, None)\n
\n
if builder_id is not None:\n
delivery_builder = getattr(portal.portal_deliveries,builder_id,None)\n
if delivery_builder is not None:\n if delivery_builder is not None:\n
explanation_uid_list = [order.getUid(),context.getUid()]\n explanation_uid_list = [order.getUid(),context.getUid()]\n
delivery_builder.activate(activity=\'SQLQueue\',after_tag=tag).build(explanation_uid=explanation_uid_list)\n delivery_builder.activate(activity=\'SQLQueue\',after_tag=tag).build(explanation_uid=explanation_uid_list)\n
else:\n
log(\'ProductionPackingList_doSolveActions\',\'Builder %s not found\'%(builder_id,),200)\n
else:\n
log(\'ProductionPackingList_doSolveActions\',\'Portal type %s has no builder\'%(packing_list_portal_type,),200)\n
\n
\n
\n \n
message = context.Base_translateString(\'%s updated.\'%(packing_list_portal_type,))\n message = context.Base_translateString(\'%s updated.\'%(packing_list_portal_type,))\n
return context.Base_redirect(form_id, keep_items = {\'portal_status_message\' : message} )\n return context.Base_redirect(form_id, keep_items = {\'portal_status_message\' : message} )\n
...@@ -185,9 +188,15 @@ return context.Base_redirect(form_id, keep_items = {\'portal_status_message\' : ...@@ -185,9 +188,15 @@ return context.Base_redirect(form_id, keep_items = {\'portal_status_message\' :
<string>tag</string> <string>tag</string>
<string>portal</string> <string>portal</string>
<string>packing_list_portal_type</string> <string>packing_list_portal_type</string>
<string>simulation_tool</string>
<string>split_and_defer</string> <string>split_and_defer</string>
<string>packing_list_portal_type_delivery_builder_mapping</string> <string>packing_list_portal_type_delivery_builder_mapping</string>
<string>order</string>
<string>applied_rule</string>
<string>None</string> <string>None</string>
<string>builder_id</string>
<string>getattr</string>
<string>delivery_builder</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>line_key</string> <string>line_key</string>
<string>_getitem_</string> <string>_getitem_</string>
...@@ -196,11 +205,11 @@ return context.Base_redirect(form_id, keep_items = {\'portal_status_message\' : ...@@ -196,11 +205,11 @@ return context.Base_redirect(form_id, keep_items = {\'portal_status_message\' :
<string>quantity</string> <string>quantity</string>
<string>movement</string> <string>movement</string>
<string>choice</string> <string>choice</string>
<string>order</string> <string>sum</string>
<string>applied_rule</string> <string>append</string>
<string>builder_id</string> <string>$append0</string>
<string>getattr</string> <string>x</string>
<string>delivery_builder</string> <string>prevision_quantity</string>
<string>explanation_uid_list</string> <string>explanation_uid_list</string>
<string>message</string> <string>message</string>
</tuple> </tuple>
......
...@@ -88,13 +88,17 @@ ...@@ -88,13 +88,17 @@
<value> <value>
<list> <list>
<tuple> <tuple>
<string>Split and defer</string> <string>Split and Defer</string>
<string>SplitAndDefer</string> <string>SplitAndDefer</string>
</tuple> </tuple>
<tuple> <tuple>
<string>Accept</string> <string>Accept</string>
<string>CopyToTarget</string> <string>CopyToTarget</string>
</tuple> </tuple>
<tuple>
<string>Adopt</string>
<string>AdoptPrevision</string>
</tuple>
</list> </list>
</value> </value>
</item> </item>
......
344 345
\ No newline at end of file \ No newline at end of file
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