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