feat: wmaterial添加外协字段及相关调整
This commit is contained in:
parent
b8994b94c1
commit
5289e71280
|
@ -50,7 +50,8 @@ class WMaterialFilter(filters.FilterSet):
|
||||||
"mgroup__name": ["exact", "in"],
|
"mgroup__name": ["exact", "in"],
|
||||||
"count": ["gte", "lte", "exact"],
|
"count": ["gte", "lte", "exact"],
|
||||||
"notok_sign": ["exact", "in", "isnull"],
|
"notok_sign": ["exact", "in", "isnull"],
|
||||||
"count_xtest": ["gte", "isnull"]
|
"count_xtest": ["gte", "isnull"],
|
||||||
|
"supplier": ["exact"],
|
||||||
}
|
}
|
||||||
|
|
||||||
class MlogFilter(filters.FilterSet):
|
class MlogFilter(filters.FilterSet):
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 3.2.12 on 2024-08-30 01:17
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('pum', '0008_auto_20240731_1829'),
|
||||||
|
('wpm', '0062_auto_20240828_1052'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='wmaterial',
|
||||||
|
name='supplier',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='pum.supplier', verbose_name='外协供应商'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -97,6 +97,7 @@ class WMaterial(CommonBDModel):
|
||||||
state = models.PositiveSmallIntegerField('状态', default=10, choices=((10, '合格'), (20, '不合格'), (30, '返修'), (40, '检验'), (50, '报废')))
|
state = models.PositiveSmallIntegerField('状态', default=10, choices=((10, '合格'), (20, '不合格'), (30, '返修'), (40, '检验'), (50, '报废')))
|
||||||
material = models.ForeignKey(
|
material = models.ForeignKey(
|
||||||
Material, verbose_name='物料', on_delete=models.CASCADE, related_name='wm_m')
|
Material, verbose_name='物料', on_delete=models.CASCADE, related_name='wm_m')
|
||||||
|
supplier = models.ForeignKey(Supplier, verbose_name='外协供应商', on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
mgroup = models.ForeignKey(Mgroup, verbose_name='所在工段', on_delete=models.CASCADE, null=True, blank=True)
|
mgroup = models.ForeignKey(Mgroup, verbose_name='所在工段', on_delete=models.CASCADE, null=True, blank=True)
|
||||||
batch = models.CharField('批次号', max_length=50)
|
batch = models.CharField('批次号', max_length=50)
|
||||||
count = models.PositiveIntegerField('当前数量', default=0)
|
count = models.PositiveIntegerField('当前数量', default=0)
|
||||||
|
|
|
@ -172,6 +172,7 @@ class SflogExpSerializer(CustomModelSerializer):
|
||||||
|
|
||||||
class WMaterialSerializer(CustomModelSerializer):
|
class WMaterialSerializer(CustomModelSerializer):
|
||||||
material_ = MaterialSimpleSerializer(source='material', read_only=True)
|
material_ = MaterialSimpleSerializer(source='material', read_only=True)
|
||||||
|
supplier_name = serializers.CharField(source='supplier.name', read_only=True)
|
||||||
material_name = serializers.StringRelatedField(
|
material_name = serializers.StringRelatedField(
|
||||||
source='material', read_only=True)
|
source='material', read_only=True)
|
||||||
mgroup_name = serializers.StringRelatedField(source='mgroup.name', read_only=True)
|
mgroup_name = serializers.StringRelatedField(source='mgroup.name', read_only=True)
|
||||||
|
|
|
@ -204,6 +204,7 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
belong_dept = mgroup.belong_dept
|
belong_dept = mgroup.belong_dept
|
||||||
material_out = mlog.material_out
|
material_out = mlog.material_out
|
||||||
material_in = mlog.material_in
|
material_in = mlog.material_in
|
||||||
|
supplier = mlog.supplier # 外协
|
||||||
if material_in: # 需要进行车间库存管理
|
if material_in: # 需要进行车间库存管理
|
||||||
m_ins = Mlogb.objects.filter(mlog=mlog, material_in__isnull=False)
|
m_ins = Mlogb.objects.filter(mlog=mlog, material_in__isnull=False)
|
||||||
if m_ins.exists():
|
if m_ins.exists():
|
||||||
|
@ -271,6 +272,8 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
wm.count = wm.count + mo_count
|
wm.count = wm.count + mo_count
|
||||||
wm.count_eweight = mo_count_eweight
|
wm.count_eweight = mo_count_eweight
|
||||||
wm.update_by = user
|
wm.update_by = user
|
||||||
|
if supplier is not None:
|
||||||
|
wm.supplier = supplier
|
||||||
wm.save()
|
wm.save()
|
||||||
|
|
||||||
mlog.submit_time = now
|
mlog.submit_time = now
|
||||||
|
|
|
@ -112,7 +112,7 @@ class WMaterialViewSet(ListModelMixin, CustomGenericViewSet):
|
||||||
perms_map = {'get': '*'}
|
perms_map = {'get': '*'}
|
||||||
queryset = WMaterial.objects.filter(count__gt=0)
|
queryset = WMaterial.objects.filter(count__gt=0)
|
||||||
serializer_class = WMaterialSerializer
|
serializer_class = WMaterialSerializer
|
||||||
select_related_fields = ['material', 'belong_dept', 'material__process']
|
select_related_fields = ['material', 'belong_dept', 'material__process', 'supplier']
|
||||||
search_fields = ['material__name',
|
search_fields = ['material__name',
|
||||||
'material__number', 'material__specification', 'batch', 'material__model']
|
'material__number', 'material__specification', 'batch', 'material__model']
|
||||||
filterset_class = WMaterialFilter
|
filterset_class = WMaterialFilter
|
||||||
|
|
Loading…
Reference in New Issue