Commit 405e8ad7 authored by Romain Courteaud's avatar Romain Courteaud

Remove buildOrderList (use OrderBuilder instead).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3451 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5181ec66
......@@ -739,137 +739,6 @@ class SimulationTool (BaseTool):
+ list(self.getPortalReservedInventoryStateList()) + list(self.getPortalCurrentInventoryStateList()))
return self.getTrackingList(**kw)
#######################################################
# Movement Group Collection / Delivery Creation
def buildOrderList(self, movement_group):
# Build orders from a list of movements (attached to orders)
order_list = []
if movement_group is not None:
for order_group in movement_group.group_list:
if order_group.order is None:
# Only build if there is not order yet
for path_group in order_group.group_list :
if path_group.destination.find('site/Stock_PF') >=0 :
# Build a Production Order
delivery_module = self.ordre_fabrication
delivery_type = 'Production Order'
delivery_line_type = delivery_type + ' Line'
delivery_cell_type = 'Delivery Cell'
else:
# Build a Purchase Order
delivery_module = self.commande_achat
delivery_type = 'Purchase Order'
delivery_line_type = delivery_type + ' Line'
delivery_cell_type = 'Delivery Cell'
# we create a new delivery for each DateGroup
for date_group in path_group.group_list :
for resource_group in date_group.group_list :
# Create a new production Order for each resource (Modele)
modele_url_items = resource_group.resource.split('/')
modele_id = modele_url_items[len(modele_url_items)-1]
try :
modele_object = self.getPortalObject().modele[modele_id]
except :
modele_object = None
if modele_object is not None :
of_description = modele_id + ' ' + modele_object.getDefaultDestinationTitle('')
else :
of_description = modele_id
new_delivery_id = str(delivery_module.generateNewId())
self.portal_types.constructContent(type_name = delivery_type,
container = delivery_module,
id = new_delivery_id,
start_date = date_group.start_date,
stop_date = date_group.stop_date,
source = path_group.source,
destination = path_group.destination,
source_section = path_group.source_section,
destination_section = path_group.destination_section,
description = of_description,
title = new_delivery_id
)
delivery = delivery_module[new_delivery_id]
# the new delivery is added to the order_list
order_list.append(delivery)
# Create each delivery_line in the new delivery
new_delivery_line_id = str(delivery.generateNewId())
self.portal_types.constructContent(type_name = delivery_line_type,
container = delivery,
id = new_delivery_line_id,
resource = resource_group.resource,
)
delivery_line = delivery[new_delivery_line_id]
line_variation_category_list = []
line_variation_base_category_dict = {}
# compute line_variation_base_category_list and
# line_variation_category_list for new delivery_line
for variant_group in resource_group.group_list :
for variation_item in variant_group.category_list :
if not variation_item in line_variation_category_list :
line_variation_category_list.append(variation_item)
variation_base_category_items = variation_item.split('/')
if len(variation_base_category_items) > 0 :
line_variation_base_category_dict[variation_base_category_items[0]] = 1
# update variation_base_category_list and line_variation_category_list for delivery_line
line_variation_base_category_list = line_variation_base_category_dict.keys()
delivery_line.setVariationBaseCategoryList(line_variation_base_category_list)
delivery_line.setVariationCategoryList(line_variation_category_list)
# IMPORTANT : delivery cells are automatically created during setVariationCategoryList
# update quantity for each delivery_cell
for variant_group in resource_group.group_list :
#LOG('Variant_group examin',0,str(variant_group.category_list))
object_to_update = None
# if there is no variation of the resource, update delivery_line with quantities and price
if len(variant_group.category_list) == 0 :
object_to_update = delivery_line
# else find which delivery_cell is represented by variant_group
else :
categories_identity = 0
#LOG('Before Check cell',0,str(delivery_cell_type))
#LOG('Before Check cell',0,str(delivery_line.contentValues()))
for delivery_cell in delivery_line.contentValues(filter={'portal_type':'Delivery Cell'}) :
#LOG('Check cell',0,str(delivery_cell))
#LOG('Check cell',0,str(variant_group.category_list))
#LOG('Check cell',0,str(delivery_cell.getVariationCategoryList()))
if len(variant_group.category_list) == len(delivery_cell.getVariationCategoryList()) :
#LOG('Parse category',0,str(delivery_cell.getVariationCategoryList()))
for category in delivery_cell.getVariationCategoryList() :
if not category in variant_group.category_list :
#LOG('Not found category',0,str(category))
break
else :
categories_identity = 1
if categories_identity :
object_to_update = delivery_cell
break
# compute quantity and price for delivery_cell or delivery_line and
# build relation between simulation_movement and delivery_cell or delivery_line
if object_to_update is not None :
cell_quantity = 0
for movement in variant_group.movement_list :
cell_quantity += movement.getConvertedQuantity()
# We do not create a relation or modifu anything
# since planification of this movement will create new applied rule
object_to_update.edit(quantity = cell_quantity,
force_update = 1)
return order_list
#######################################################
# Capacity Management
security.declareProtected( Permissions.ModifyPortalContent, 'updateCapacity' )
......
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