diff --git a/product/ERP5/Document/DeliveryBuilder.py b/product/ERP5/Document/DeliveryBuilder.py index 817159bd45316f4f2c25e1076eed19d89588412d..5d0611e4894069c1666a1bd7bcc01a921ac8b92c 100644 --- a/product/ERP5/Document/DeliveryBuilder.py +++ b/product/ERP5/Document/DeliveryBuilder.py @@ -365,6 +365,10 @@ class DeliveryBuilder(OrderBuilder): delete_id_list = [x.getId() for x in delivery.contentValues() \ if x.getId() not in keep_id_list] delivery.deleteContent(delete_id_list) + if activate_kw: + # XXX _duplicate does not accept activate_kw. So reindex the new + # delivery again with activate_kw. + delivery.reindexObject(activate_kw=activate_kw) return delivery @@ -403,6 +407,10 @@ class DeliveryBuilder(OrderBuilder): delete_id_list = [x.getId() for x in delivery_line.contentValues() \ if x.getId() not in keep_id_list] delivery_line.deleteContent(delete_id_list) + if activate_kw: + # XXX _duplicate does not accept activate_kw. So reindex the new + # delivery line again with activate_kw. + delivery_line.reindexObject(activate_kw=activate_kw) return delivery_line @@ -430,5 +438,9 @@ class DeliveryBuilder(OrderBuilder): parent._duplicate(parent.manage_copyObjects(ids=ids))[0], (delivery_line, old_cell.getId()), {}, CopyError) cell = delivery_line[cp['new_id']] + if activate_kw: + # XXX _duplicate does not accept activate_kw. So reindex the new + # cell again with activate_kw. + cell.reindexObject(activate_kw=activate_kw) return cell diff --git a/product/ERP5/Document/OrderBuilder.py b/product/ERP5/Document/OrderBuilder.py index 854996b26c78e05a4c68c44095e98399d8b8f69e..8fe99a06cb956edd6abb0af93bdf29be792c628d 100644 --- a/product/ERP5/Document/OrderBuilder.py +++ b/product/ERP5/Document/OrderBuilder.py @@ -407,8 +407,6 @@ class OrderBuilder(XMLObject, Amount, Predicate): """ Build delivery from a list of movement """ - # FIXME make sure that activate_kw is used for all active objects - # generated from this method and methods called from this method. if movement_group_node_list is None: movement_group_node_list = [] if divergence_list is None: @@ -458,7 +456,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): # Put properties on delivery if property_dict: property_dict.setdefault('edit_order', ('stop_date', 'start_date')) - delivery.edit(**property_dict) + delivery.edit(activate_kw=activate_kw, **property_dict) # Then, create delivery lines delivery_line_portal_type = self.getDeliveryLinePortalType() @@ -539,7 +537,8 @@ class OrderBuilder(XMLObject, Amount, Predicate): # Put properties on delivery line if property_dict: property_dict.setdefault('edit_order', ('stop_date', 'start_date')) - delivery_line.edit(force_update=1, **property_dict) + delivery_line.edit(force_update=1, activate_kw=activate_kw, + **property_dict) if movement_group_node.getCurrentMovementGroup().isBranch(): delivery_line_portal_type = self.getDeliveryLinePortalType() @@ -563,7 +562,8 @@ class OrderBuilder(XMLObject, Amount, Predicate): for movement in movement_group_node.getMovementList(): variation_category_set.update(movement.getVariationCategoryList()) variation_category_list = sorted(variation_category_set) - delivery_line.setVariationCategoryList(variation_category_list) + delivery_line.edit(variation_category_list=variation_category_list, + activate_kw=activate_kw) # Then, create delivery movement (delivery cell or complete delivery # line) grouped_node_list = movement_group_node.getGroupList() @@ -690,6 +690,8 @@ class OrderBuilder(XMLObject, Amount, Predicate): cell = self._createDeliveryCell(delivery_line, movement, activate_kw, base_id, cell_key) vcl = movement.getVariationCategoryList() + # _createDeliveryCell calls reindexObject, so no need to use + # edit here. cell._edit(category_list=vcl, # XXX hardcoded value mapped_value_property_list=('quantity', 'price'), @@ -722,7 +724,8 @@ class OrderBuilder(XMLObject, Amount, Predicate): property_dict['quantity'] = simulation_movement.getQuantity() property_dict['price'] = simulation_movement.getPrice() # Update properties on object (quantity, price...) - delivery_movement._edit(force_update=1, **property_dict) + delivery_movement.edit(force_update=1, activate_kw=activate_kw, + **property_dict) @UnrestrictedMethod def callAfterBuildingScript(self, delivery_list, movement_list=None, **kw):