diff --git a/apps/mtm/migrations/0036_material_unit_price.py b/apps/mtm/migrations/0036_material_unit_price.py new file mode 100644 index 00000000..2862eac8 --- /dev/null +++ b/apps/mtm/migrations/0036_material_unit_price.py @@ -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='单价'), + ), + ] diff --git a/apps/mtm/models.py b/apps/mtm/models.py index 2db5c76d..31ab88cf 100644 --- a/apps/mtm/models.py +++ b/apps/mtm/models.py @@ -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 = '物料表' diff --git a/apps/mtm/services.py b/apps/mtm/services.py index e457c4e3..e889a685 100644 --- a/apps/mtm/services.py +++ b/apps/mtm/services.py @@ -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: diff --git a/media/default/template/material.xlsx b/media/default/template/material.xlsx index 5d151b6e..19a678a3 100644 Binary files a/media/default/template/material.xlsx and b/media/default/template/material.xlsx differ