feat: material添加单价字段
This commit is contained in:
parent
c31bd32fb5
commit
c125652de4
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.12 on 2024-07-25 05:09
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mtm', '0035_process_store_notok'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='material',
|
||||
name='unit_price',
|
||||
field=models.PositiveIntegerField(blank=True, null=True, verbose_name='单价'),
|
||||
),
|
||||
]
|
|
@ -72,6 +72,7 @@ class Material(CommonAModel):
|
|||
need_route = models.BooleanField('是否需要定义工艺路线', default=False)
|
||||
components = models.JSONField('组件', default=dict, null=False, blank=True)
|
||||
brothers = models.JSONField('兄弟件', default=list, null=False, blank=True)
|
||||
unit_price = models.PositiveIntegerField('单价', null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = '物料表'
|
||||
|
|
|
@ -77,6 +77,7 @@ def daoru_material(path: str):
|
|||
model = sheet[f'd{i}'].value.replace(' ', '')
|
||||
unit = sheet[f'e{i}'].value.replace(' ', '')
|
||||
count_safe = sheet[f'g{i}'].value
|
||||
unit_price = sheet[f'h{i}'].value
|
||||
except Exception as e:
|
||||
raise ParseError(f'{i}行物料信息错误: {str(e)}')
|
||||
if type in [20, 30]:
|
||||
|
@ -90,7 +91,8 @@ 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(), 'count_safe': count_safe}
|
||||
'model': model, 'unit': unit, 'number': f'm{type}_{ranstr(6)}', 'id': idWorker.get_id(),
|
||||
'count_safe': count_safe, 'unit_price': unit_price}
|
||||
material, is_created = Material.objects.get_or_create(
|
||||
**filters, defaults=default)
|
||||
if not is_created:
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue