Commit b042c5df authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_production_planning: use cell id to get resource,date is wrong

parent f13738a1
......@@ -2,11 +2,13 @@ from DateTime import DateTime
from Products.ERP5Type.DateUtils import addToDate
portal = context.getPortalObject()
line_list, column_list = context.ProductionPlanning_getCellRange()
line_id_list = [x[0] for x in line_list]
column_id_list = [x[0] for x in column_list]
created_production_order_dict = {}
for cell in context.getCellValueList():
for cell_keys in context.getCellKeys():
cell_id = context.keyToId(cell_keys)
if cell_id is not None:
cell = context.get(cell_id)
if cell is not None:
production_order_line = cell.getSpecialiseValue()
if production_order_line:
if production_order_line.getQuantity() != cell.getQuantity():
......@@ -17,9 +19,7 @@ for cell in context.getCellValueList():
comment='Modified by production planning %s' % context.getRelativeUrl())
else:
# It's a new cell, create producton order&production order line
[_, line_index, column_index] = cell.getId().split('_')
resource_uid = line_id_list[int(line_index)]
start_date = column_id_list[int(column_index)]
[resource_uid,start_date] = cell_keys
# Check if it existes a production order for the date
kw = {
'portal_type': 'Production Order',
......@@ -52,5 +52,6 @@ for cell in context.getCellValueList():
production_order_line,
"edit_action",
comment='Added by production planning %s' % context.getRelativeUrl())
if portal.portal_workflow.isTransitionPossible(context, 'record'):
context.record()
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