Rename SaleOrder_getRuleReference to Delivery_getRuleReference

Also change it so that if no rules match the delivery, None is returned for 'rule reference' instead of raising a SimulationError, enabling deliveries that are only ever going to be simulated and never created from scratch.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45621 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 64843881
......@@ -50,16 +50,46 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return \'default_order_rule\'\n
<value> <string>from Products.ERP5Type.Errors import SimulationError\n
\n
\n
if context.getTradePhase() is None:\n
# XXX-Leo: Maybe refactor this block into a Delivery_getTradePhase script\n
business_link = context.Delivery_getBusinessLink()\n
# context = context.asContext(trade_phase=business_link.getTradePhase()) is not working...\n
context = context.asContext()\n
context.setTradePhase(business_link.getTradePhase())\n
\n
rule_list = context.getPortalObject().portal_rules.searchRuleList(context)\n
\n
if not len(rule_list):\n
# No applied rule will be created.\n
# XXX-Leo: Should we check self.isSimulated() and raise an error if not? \n
return None\n
\n
try:\n
rule, = rule_list\n
except ValueError:\n
raise SimulationError(\'Exactly one root rule should match %r, got %r\' %\n
(context.getPath(), rule_list))\n
return rule.getReference()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SaleOrder_getRuleReference</string> </value>
<value> <string>Delivery_getRuleReference</string> </value>
</item>
</dictionary>
</pickle>
......
1121
\ No newline at end of file
1122
\ 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