Commit 396fb981 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_mrp_quality_assurance: show 'already processed' msg for serial number...

erp5_mrp_quality_assurance: show 'already processed' msg for serial number already used for same VIN
parent c8b27751
......@@ -16,6 +16,8 @@ for traceability_input in context.Base_getExpectedTraceabilityInputList():
data_dict = context.Base_generateValideTraceabilityDataDict(traceability_data)
unprocess_data_list = []
processed_data_list = []
already_used_list = []
ME_vin = context.getAggregateValue(portal_type='VIN')
for product_reference, serial_number_list in data_dict.iteritems():
if product_reference in traceability_input_dict:
......@@ -37,8 +39,11 @@ for product_reference, serial_number_list in data_dict.iteritems():
part_product = context.portal_catalog.getResultValue(portal_type='Product', reference=part_reference)
if part_product and part_product.getProductLine() == 'part/radio':
is_for_radio = True
if affected_vin and (not is_for_radio):
# same serial number affected to same VIN
if affected_vin == ME_vin:
already_used_list.append(serial_number)
else:
unprocess_data_list = unprocess_data_list + [serial_number]
continue
else:
......@@ -76,16 +81,30 @@ for product_reference, serial_number_list in data_dict.iteritems():
traceability_input.post()
processed_data_list.append(serial_number)
else:
unprocess_data_list = unprocess_data_list + serial_number_list
for unprocess_number in serial_number_list:
unprocess_number_value = getattr(context.quality_assurance_module, unprocess_number, None)
if unprocess_number_value and (unprocess_number_value.getAggregateValue(portal_type='VIN') == ME_vin):
already_used_list.append(unprocess_number)
else:
unprocess_data_list.append(unprocess_number)
if unprocess_data_list:
unprocess_data_list = list(set(unprocess_data_list))
unprocess_data_list = [x for x in unprocess_data_list if x not in processed_data_list]
if unprocess_data_list:
if unprocess_data_list or already_used_list:
msg = ''
if unprocess_data_list:
msg = msg + translateString("Those data are not processed")
if already_used_list:
msg= msg + translateString(
"Data already processed : ${already_processed}",
mapping = {
'already_processed' : '\n'.join(already_used_list)
}
)
return context.Base_redirect('view_traceability_input', keep_items={
'unprocess_data_list': unprocess_data_list,
'portal_status_message': translateString("Those data are not processed"),
'portal_status_message': msg,
'portal_status_level': 'error'})
return context.Base_redirect('view', keep_items={'portal_status_message': translateString("Data is posted")})
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