Commit 12f6f357 authored by Alexandre Boeglin's avatar Alexandre Boeglin

remove remaining _test methods from Rule classes

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17654 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent db918d7e
......@@ -65,27 +65,6 @@ class PaymentRule(Rule):
, PropertySheet.Task
)
def _test(self, movement):
"""
Tests if the rule (still) applies
"""
if 'receivable' in movement.getId() : ### TODO: expand 'payable' too
parent = movement.getParentValue()
parent_rule_value = parent.getSpecialiseValue()
if parent_rule_value is None:
return 0
parent_rule_type = parent_rule_value.getPortalType()
if parent_rule_type in ('Invoice Transaction Rule',
'Invoice Rule'):
if parent_rule_type == 'Invoice Rule':
delivery_movement = movement.getDeliveryValue()
if delivery_movement is not None:
if delivery_movement.getPortalType() not in \
movement.getPortalAccountingMovementTypeList():
return 0
return 1
return 0
security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule, **kw):
"""
......
......@@ -63,43 +63,6 @@ class TransformationRule(Rule):
# Class variable
simulation_movement_portal_type = "Simulation Movement"
def _test(self, movement):
"""
Tests if the rule (still) applies
"""
# Test if we must transform
# The test should actually be based on nodes, paths
# and capacities, which is not possible now
result = 1
# Only apply to Order applied rule
root_applied_rule = movement.getRootAppliedRule()
root_rule = root_applied_rule.getSpecialiseValue()
order = root_applied_rule.getCausalityValue()
root_movement = movement.getRootSimulationMovement()
# Test movement
if (root_rule is None) or\
(root_rule.getPortalType() != "Production Order Rule") or\
(order is None) or\
(movement.getResourceValue() is None) or\
(movement.getSourceValue() is None) or\
(movement.getResourceValue() != root_movement.getResourceValue()):
# We only produced what is asked on the Production Order
result = 0
else:
supply_chain = self.getSupplyChain(movement.getParentValue())
parent_supply_link = self.getCurrentSupplyLink(movement)
current_tranfo_link_list = supply_chain.\
getPreviousProductionSupplyLinkList(parent_supply_link)
length = len(current_tranfo_link_list)
if length == 0:
result = 0
elif length > 1:
result = 0
# XXX FIXME: implementation needed
raise TransformationRuleError,\
"TransformationRule not able to use multiple SupplyLink."
return result
# Simulation workflow
security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule, **kw):
......
......@@ -151,33 +151,6 @@ class TransformationSourcingRule(Rule):
# Class variable
simulation_movement_portal_type = "Simulation Movement"
def _test(self, movement):
"""
Tests if the rule (still) applies
"""
# Test if we must transform
# The test should actually be based on nodes, paths
# and capacities, which is not possible now
result = 1
# Only apply to Order applied rule
root_applied_rule = movement.getRootAppliedRule()
root_rule = root_applied_rule.getSpecialiseValue()
order = root_applied_rule.getCausalityValue()
# Test some properties to see if we are really
# in a 'production' expand.
if (root_rule is None) or\
(root_rule.getPortalType() != "Production Order Rule") or\
(order is None) or\
(movement.getResourceValue() is None) or\
(movement.getSourceValue() is None):
result = 0
else:
supply_chain = self.getSupplyChain(movement.getParentValue())
parent_supply_link = self.getCurrentSupplyLink(movement)
if not supply_chain.test(parent_supply_link, movement):
result = 0
return result
security.declareProtected(Permissions.ModifyPortalContent, 'expand')
def expand(self, applied_rule, activate_kw=None,**kw):
"""
......
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