feat: material增加tracking字段
This commit is contained in:
parent
e62f7e5a9c
commit
ddb517d1f8
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 3.2.12 on 2024-12-18 06:31
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mtm', '0047_route_div_number'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='material',
|
||||
name='tracking',
|
||||
field=models.PositiveSmallIntegerField(choices=[(10, '批次'), (20, '单件')], default=10, verbose_name='追踪方式'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='material',
|
||||
name='sort',
|
||||
field=models.FloatField(default=1, verbose_name='排序'),
|
||||
),
|
||||
]
|
|
@ -55,6 +55,9 @@ class Material(CommonAModel):
|
|||
(MA_TYPE_OFFICE, '办公用品')
|
||||
)
|
||||
|
||||
MA_TRACKING_BATCH = 10
|
||||
MA_TRACKING_SINGLE = 20
|
||||
|
||||
name = models.CharField('名称', max_length=50)
|
||||
cate = models.CharField('大类', max_length=20, default='', blank=True)
|
||||
number = models.CharField('编号', max_length=100, null=True, blank=True)
|
||||
|
@ -66,8 +69,11 @@ class Material(CommonAModel):
|
|||
type = models.PositiveSmallIntegerField(
|
||||
'物料类型', choices=type_choices, default=1, help_text=str(type_choices))
|
||||
testitems = models.JSONField('检测项目', default=list, blank=True)
|
||||
sort = models.PositiveSmallIntegerField('排序', default=1)
|
||||
sort = models.FloatField('排序', default=1)
|
||||
unit = models.CharField('基准计量单位', default='个', max_length=10)
|
||||
tracking = models.PositiveSmallIntegerField("追踪方式", default=10,
|
||||
choices=((MA_TRACKING_BATCH, '批次'),
|
||||
(MA_TRACKING_SINGLE, '单件')))
|
||||
count = models.DecimalField('总库存', max_digits=14, decimal_places=3, default=0)
|
||||
count_mb = models.DecimalField('仓库库存', max_digits=14, decimal_places=3, default=0)
|
||||
count_wm = models.DecimalField('车间库存', max_digits=14, decimal_places=3, default=0)
|
||||
|
|
|
@ -183,7 +183,7 @@ class RouteSerializer(CustomModelSerializer):
|
|||
"""
|
||||
material = instance.material
|
||||
process = instance.process
|
||||
material_out = Material.objects.get_queryset(all=True).filter(type=Material.MA_TYPE_HALFGOOD, parent=material, process=process).first()
|
||||
material_out: Material = Material.objects.get_queryset(all=True).filter(type=Material.MA_TYPE_HALFGOOD, parent=material, process=process).first()
|
||||
if material_out:
|
||||
material_out.is_deleted = False
|
||||
if material_out.parent == material:
|
||||
|
@ -191,6 +191,7 @@ class RouteSerializer(CustomModelSerializer):
|
|||
material_out.model = material.model
|
||||
material_out.specification = material.specification
|
||||
material_out.cate = material.cate
|
||||
material_out.tracking = material.tracking
|
||||
material_out.save()
|
||||
instance.material_out = material_out
|
||||
instance.save()
|
||||
|
@ -201,6 +202,7 @@ class RouteSerializer(CustomModelSerializer):
|
|||
if material_out.parent is None:
|
||||
material_out.parent = material
|
||||
material_out.cate = material.cate
|
||||
material_out.tracking = material.tracking
|
||||
material_out.save()
|
||||
instance.material_out = material_out
|
||||
instance.save()
|
||||
|
@ -212,6 +214,7 @@ class RouteSerializer(CustomModelSerializer):
|
|||
'model': material.model,
|
||||
'type': Material.MA_TYPE_HALFGOOD,
|
||||
'cate': material.cate,
|
||||
'tracking': material.tracking,
|
||||
'create_by': self.request.user,
|
||||
'update_by': self.request.user,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue