Commit 5a8ceb20 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_mrp_quality_assurance: show vin if serial number is already used

parent fcc1d17d
Pipeline #37126 passed with stage
in 0 seconds
......@@ -16,8 +16,7 @@ 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')
already_used_dict = {}
for product_reference, serial_number_list in data_dict.iteritems():
if product_reference in traceability_input_dict:
......@@ -40,11 +39,7 @@ for product_reference, serial_number_list in data_dict.iteritems():
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]
already_used_dict[serial_number] = affected_vin.getReference()
continue
else:
serial_item = context.quality_assurance_module.newContent(
......@@ -83,8 +78,8 @@ for product_reference, serial_number_list in data_dict.iteritems():
else:
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)
if unprocess_number_value and unprocess_number_value.getAggregateReference(portal_type='VIN'):
already_used_dict[unprocess_number] = unprocess_number_value.getAggregateReference(portal_type='VIN')
else:
unprocess_data_list.append(unprocess_number)
......@@ -92,15 +87,18 @@ 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 or already_used_list:
if unprocess_data_list or already_used_dict:
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}",
if already_used_dict:
msg = msg + '\n' + translateString("Already used:")
for serial_number, vin in already_used_dict.iteritems():
msg= msg + '\n' + translateString(
"${serial_number}: ${vin}",
mapping = {
'already_processed' : '\n'.join(already_used_list)
'serial_number' : serial_number,
'vin': vin
}
)
return context.Base_redirect('view_traceability_input', keep_items={
......
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