Commit 149d6be0 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Rewrite the code to look up for current delivery, because it did not work when...

Rewrite the code to look up for current delivery, because it did not work when the list of movement group nodes is empty.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38277 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 82ac8dae
...@@ -301,8 +301,8 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -301,8 +301,8 @@ class OrderBuilder(XMLObject, Amount, Predicate):
new_property_dict.update(tmp_property_dict) new_property_dict.update(tmp_property_dict)
return result, new_property_dict return result, new_property_dict
def _findUpdatableObject(self, instance_list, movement_group_node_list, def _findUpdatableObject(self, instance_list, current_movement_group_node,
divergence_list): movement_group_node_list, divergence_list):
# FIXME this code may generate inconsistent results, because # FIXME this code may generate inconsistent results, because
# MovementGroupNode.test can return anything else but the # MovementGroupNode.test can return anything else but the
# property dict. So it would be better to use the test method # property dict. So it would be better to use the test method
...@@ -322,21 +322,16 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -322,21 +322,16 @@ class OrderBuilder(XMLObject, Amount, Predicate):
property_dict[k] = v property_dict[k] = v
else: else:
# we want to check the original delivery first. # we want to check the original delivery first.
# so sort instance_list by that current is exists or not. movement = current_movement_group_node.getMovementList()[0]
try: delivery_movement = movement.getDeliveryValue()
current = movement_group_node_list[-1].getMovementList()[0].getDeliveryValue() if delivery_movement is not None:
portal = self.getPortalObject() delivery = delivery_movement.getRootDeliveryValue()
while current != portal: try:
try: instance_list.remove(delivery)
instance_list.remove(current) except ValueError:
except ValueError: pass
pass else:
else: instance_list.insert(0, delivery)
instance_list.insert(0, current)
break
current = current.getParentValue()
except AttributeError:
pass
for instance_to_update in instance_list: for instance_to_update in instance_list:
result, property_dict = self._test( result, property_dict = self._test(
instance_to_update, movement_group_node_list, divergence_list) instance_to_update, movement_group_node_list, divergence_list)
...@@ -436,7 +431,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -436,7 +431,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
# Test if we can update a existing delivery, or if we need to create # Test if we can update a existing delivery, or if we need to create
# a new one # a new one
delivery, property_dict = self._findUpdatableObject( delivery, property_dict = self._findUpdatableObject(
delivery_to_update_list, movement_group_node_list, delivery_to_update_list, movement_group_node, movement_group_node_list,
divergence_list) divergence_list)
# if all deliveries are rejected in case of update, we update the # if all deliveries are rejected in case of update, we update the
...@@ -522,8 +517,8 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -522,8 +517,8 @@ class OrderBuilder(XMLObject, Amount, Predicate):
# Test if we can update an existing line, or if we need to create a new # Test if we can update an existing line, or if we need to create a new
# one # one
delivery_line, property_dict = self._findUpdatableObject( delivery_line, property_dict = self._findUpdatableObject(
delivery_line_to_update_list, movement_group_node_list, delivery_line_to_update_list, movement_group_node,
divergence_list) movement_group_node_list, divergence_list)
if delivery_line is not None: if delivery_line is not None:
update_existing_line = 1 update_existing_line = 1
delivery_line_to_update_list.remove(delivery_line) delivery_line_to_update_list.remove(delivery_line)
...@@ -662,8 +657,8 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -662,8 +657,8 @@ class OrderBuilder(XMLObject, Amount, Predicate):
if not delivery_line.getCellKeyList(base_id=base_id): if not delivery_line.getCellKeyList(base_id=base_id):
# update line # update line
dummy, property_dict = self._findUpdatableObject( dummy, property_dict = self._findUpdatableObject(
delivery_movement_to_update_list, movement_group_node_list, delivery_movement_to_update_list, movement_group_node,
divergence_list) movement_group_node_list, divergence_list)
if delivery_movement_to_update_list: if delivery_movement_to_update_list:
if update_existing_line: if update_existing_line:
update_existing_movement = 1 update_existing_movement = 1
...@@ -674,8 +669,8 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -674,8 +669,8 @@ class OrderBuilder(XMLObject, Amount, Predicate):
object_to_update = delivery_line object_to_update = delivery_line
else: else:
object_to_update, property_dict = self._findUpdatableObject( object_to_update, property_dict = self._findUpdatableObject(
delivery_movement_to_update_list, movement_group_node_list, delivery_movement_to_update_list, movement_group_node,
divergence_list) movement_group_node_list, divergence_list)
if object_to_update is not None: if object_to_update is not None:
# We update a existing cell # We update a existing cell
# delivery_ratio of new related movement to this cell # delivery_ratio of new related movement to this cell
......
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