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(): ...@@ -16,8 +16,7 @@ for traceability_input in context.Base_getExpectedTraceabilityInputList():
data_dict = context.Base_generateValideTraceabilityDataDict(traceability_data) data_dict = context.Base_generateValideTraceabilityDataDict(traceability_data)
unprocess_data_list = [] unprocess_data_list = []
processed_data_list = [] processed_data_list = []
already_used_list = [] already_used_dict = {}
ME_vin = context.getAggregateValue(portal_type='VIN')
for product_reference, serial_number_list in data_dict.iteritems(): for product_reference, serial_number_list in data_dict.iteritems():
if product_reference in traceability_input_dict: if product_reference in traceability_input_dict:
...@@ -40,11 +39,7 @@ for product_reference, serial_number_list in data_dict.iteritems(): ...@@ -40,11 +39,7 @@ for product_reference, serial_number_list in data_dict.iteritems():
if part_product and part_product.getProductLine() == 'part/radio': if part_product and part_product.getProductLine() == 'part/radio':
is_for_radio = True is_for_radio = True
if affected_vin and (not is_for_radio): if affected_vin and (not is_for_radio):
# same serial number affected to same VIN already_used_dict[serial_number] = affected_vin.getReference()
if affected_vin == ME_vin:
already_used_list.append(serial_number)
else:
unprocess_data_list = unprocess_data_list + [serial_number]
continue continue
else: else:
serial_item = context.quality_assurance_module.newContent( serial_item = context.quality_assurance_module.newContent(
...@@ -83,8 +78,8 @@ for product_reference, serial_number_list in data_dict.iteritems(): ...@@ -83,8 +78,8 @@ for product_reference, serial_number_list in data_dict.iteritems():
else: else:
for unprocess_number in serial_number_list: for unprocess_number in serial_number_list:
unprocess_number_value = getattr(context.quality_assurance_module, unprocess_number, None) 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): if unprocess_number_value and unprocess_number_value.getAggregateReference(portal_type='VIN'):
already_used_list.append(unprocess_number) already_used_dict[unprocess_number] = unprocess_number_value.getAggregateReference(portal_type='VIN')
else: else:
unprocess_data_list.append(unprocess_number) unprocess_data_list.append(unprocess_number)
...@@ -92,15 +87,18 @@ if unprocess_data_list: ...@@ -92,15 +87,18 @@ if unprocess_data_list:
unprocess_data_list = list(set(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] 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 = '' msg = ''
if unprocess_data_list: if unprocess_data_list:
msg = msg + translateString("Those data are not processed") msg = msg + translateString("Those data are not processed")
if already_used_list: if already_used_dict:
msg= msg + translateString( msg = msg + '\n' + translateString("Already used:")
"Data already processed : ${already_processed}", for serial_number, vin in already_used_dict.iteritems():
msg= msg + '\n' + translateString(
"${serial_number}: ${vin}",
mapping = { mapping = {
'already_processed' : '\n'.join(already_used_list) 'serial_number' : serial_number,
'vin': vin
} }
) )
return context.Base_redirect('view_traceability_input', keep_items={ 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