Commit 99e0cf9b authored by Yoshinori Okuji's avatar Yoshinori Okuji

No need to record updated movements any longer by passing around movements to be update.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38220 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2422735b
...@@ -96,6 +96,10 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -96,6 +96,10 @@ class OrderBuilder(XMLObject, Amount, Predicate):
, PropertySheet.DeliveryBuilder , PropertySheet.DeliveryBuilder
) )
# XXX it would be better to make the base id configurable at
# each builder.
matrix_base_id = 'movement'
security.declarePublic('build') security.declarePublic('build')
def build(self, applied_rule_uid=None, movement_relative_url_list=None, def build(self, applied_rule_uid=None, movement_relative_url_list=None,
delivery_relative_url_list=None, movement_list=None, **kw): delivery_relative_url_list=None, movement_list=None, **kw):
...@@ -554,6 +558,13 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -554,6 +558,13 @@ class OrderBuilder(XMLObject, Amount, Predicate):
# If no group is defined for cell, we need to continue, in order to # If no group is defined for cell, we need to continue, in order to
# save the quantity value # save the quantity value
if grouped_node_list: if grouped_node_list:
base_id = self.matrix_base_id
getCell = delivery_line.getCell
delivery_movement_to_update_list = []
for cell_key in delivery_line.getCellKeyList(base_id=base_id):
cell = getCell(base_id=base_id, *cell_key)
if cell is not None:
delivery_movement_to_update_list.append(cell)
for grouped_node in grouped_node_list: for grouped_node in grouped_node_list:
self._processDeliveryCellGroup( self._processDeliveryCellGroup(
delivery_line, delivery_line,
...@@ -561,6 +572,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -561,6 +572,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
self.getDeliveryCellMovementGroupList()[1:], self.getDeliveryCellMovementGroupList()[1:],
update_existing_line=update_existing_line, update_existing_line=update_existing_line,
divergence_list=divergence_list, divergence_list=divergence_list,
delivery_movement_to_update_list=delivery_movement_to_update_list,
activate_kw=activate_kw, activate_kw=activate_kw,
force_update=force_update) force_update=force_update)
else: else:
...@@ -570,6 +582,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -570,6 +582,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
[], [],
update_existing_line=update_existing_line, update_existing_line=update_existing_line,
divergence_list=divergence_list, divergence_list=divergence_list,
delivery_movement_to_update_list=[delivery_line],
activate_kw=activate_kw, activate_kw=activate_kw,
force_update=force_update) force_update=force_update)
...@@ -589,6 +602,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -589,6 +602,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
collect_order_list, movement_group_node_list=None, collect_order_list, movement_group_node_list=None,
update_existing_line=0, update_existing_line=0,
divergence_list=None, divergence_list=None,
delivery_movement_to_update_list=None,
activate_kw=None, force_update=0): activate_kw=None, force_update=0):
""" """
Build delivery cell from a list of movement on a delivery line Build delivery cell from a list of movement on a delivery line
...@@ -596,6 +610,8 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -596,6 +610,8 @@ class OrderBuilder(XMLObject, Amount, Predicate):
""" """
if movement_group_node_list is None: if movement_group_node_list is None:
movement_group_node_list = [] movement_group_node_list = []
if delivery_movement_to_update_list is None:
delivery_movement_to_update_list = []
if divergence_list is None: if divergence_list is None:
divergence_list = [] divergence_list = []
# do not use 'append' or '+=' because they are destructive. # do not use 'append' or '+=' because they are destructive.
...@@ -611,6 +627,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -611,6 +627,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
movement_group_node_list=movement_group_node_list, movement_group_node_list=movement_group_node_list,
update_existing_line=update_existing_line, update_existing_line=update_existing_line,
divergence_list=divergence_list, divergence_list=divergence_list,
delivery_movement_to_update_list=delivery_movement_to_update_list,
activate_kw=activate_kw, activate_kw=activate_kw,
force_update=force_update) force_update=force_update)
else: else:
...@@ -619,8 +636,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -619,8 +636,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
raise CollectError, "DeliveryBuilder: %s unable to distinct those\ raise CollectError, "DeliveryBuilder: %s unable to distinct those\
movements: %s" % (self.getId(), str(movement_list)) movements: %s" % (self.getId(), str(movement_list))
else: else:
# XXX Hardcoded value base_id = self.matrix_base_id
base_id = 'movement'
object_to_update = None object_to_update = None
# We need to initialize the cell # We need to initialize the cell
update_existing_movement = 0 update_existing_movement = 0
...@@ -632,35 +648,28 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -632,35 +648,28 @@ class OrderBuilder(XMLObject, Amount, Predicate):
property_dict = {} property_dict = {}
if not delivery_line.getCellKeyList(base_id=base_id): if not delivery_line.getCellKeyList(base_id=base_id):
# update line # update line
if update_existing_line == 1: dummy, property_dict = self._findUpdatableObject(
if self._isUpdated(delivery_line, 'cell'): delivery_movement_to_update_list, movement_group_node_list,
object_to_update_list = []
else:
object_to_update_list = [delivery_line]
else:
object_to_update_list = []
object_to_update, property_dict = self._findUpdatableObject(
object_to_update_list, movement_group_node_list,
divergence_list) divergence_list)
if object_to_update is not None: if delivery_movement_to_update_list:
if update_existing_line:
update_existing_movement = 1 update_existing_movement = 1
del delivery_movement_to_update_list[:]
else: else:
# XXX probably an exception should be raised here.
pass
object_to_update = delivery_line object_to_update = delivery_line
else: else:
object_to_update_list = [
delivery_line.getCell(base_id=base_id, *cell_key) for cell_key in \
delivery_line.getCellKeyList(base_id=base_id) \
if delivery_line.hasCell(base_id=base_id, *cell_key)]
object_to_update, property_dict = self._findUpdatableObject( object_to_update, property_dict = self._findUpdatableObject(
object_to_update_list, movement_group_node_list, delivery_movement_to_update_list, movement_group_node_list,
divergence_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
# must be updated to 0. # must be updated to 0.
update_existing_movement = 1 update_existing_movement = 1
delivery_movement_to_update_list.remove(object_to_update)
if object_to_update is None: else:
# create a new cell # create a new cell
cell_key = movement.getVariationCategoryList( cell_key = movement.getVariationCategoryList(
omit_optional_variation=1) omit_optional_variation=1)
...@@ -678,7 +687,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -678,7 +687,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
raise MatrixError, 'Cell: %s already exists on %s' % \ raise MatrixError, 'Cell: %s already exists on %s' % \
(str(cell_key), str(delivery_line)) (str(cell_key), str(delivery_line))
object_to_update = cell object_to_update = cell
self._setUpdated(object_to_update, 'cell')
self._setDeliveryMovementProperties( self._setDeliveryMovementProperties(
object_to_update, movement, property_dict, object_to_update, movement, property_dict,
update_existing_movement=update_existing_movement, update_existing_movement=update_existing_movement,
......
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