fix: material导入可更改count_safe
This commit is contained in:
parent
70b5a4d87e
commit
eecda9e5a6
|
@ -49,6 +49,7 @@ def daoru_material(path: str):
|
||||||
'×', '*').replace(' ', '')
|
'×', '*').replace(' ', '')
|
||||||
model = sheet[f'd{i}'].value.replace(' ', '')
|
model = sheet[f'd{i}'].value.replace(' ', '')
|
||||||
unit = sheet[f'e{i}'].value.replace(' ', '')
|
unit = sheet[f'e{i}'].value.replace(' ', '')
|
||||||
|
count_safe = sheet[f'g{i}'].value
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ParseError(f'{i}行物料信息错误: {str(e)}')
|
raise ParseError(f'{i}行物料信息错误: {str(e)}')
|
||||||
if type in [20, 30]:
|
if type in [20, 30]:
|
||||||
|
@ -62,11 +63,12 @@ def daoru_material(path: str):
|
||||||
if type in [20, 30]:
|
if type in [20, 30]:
|
||||||
filters['process'] = process
|
filters['process'] = process
|
||||||
default = {'type': type, 'name': name, 'specification': specification,
|
default = {'type': type, 'name': name, 'specification': specification,
|
||||||
'model': model, 'unit': unit, 'number': f'm{type}_{ranstr(6)}', 'id': idWorker.get_id()}
|
'model': model, 'unit': unit, 'number': f'm{type}_{ranstr(6)}', 'id': idWorker.get_id(), 'count_safe': count_safe}
|
||||||
Material.objects.update_or_create(
|
material, is_created = Material.objects.get_or_create(
|
||||||
defaults=default,
|
**filters, defaults=default)
|
||||||
**filters
|
if not is_created:
|
||||||
)
|
material.count_safe = count_safe
|
||||||
|
material.save()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ParseError(f'{i}行物料有误, 导入失败--{e}')
|
raise ParseError(f'{i}行物料有误, 导入失败--{e}')
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
Loading…
Reference in New Issue