feat: mlog增加material_in字段
This commit is contained in:
parent
4460d4af61
commit
3b3434fcf1
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 3.2.12 on 2023-11-02 08:12
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('mtm', '0023_auto_20231102_1128'),
|
||||||
|
('wpm', '0027_alter_mlogb_material_out'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='mlog',
|
||||||
|
name='material_in',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='mlog_material_in', to='mtm.material', verbose_name='消耗物'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -90,6 +90,8 @@ class Mlog(CommonADModel):
|
||||||
Mtask, verbose_name='关联任务', on_delete=models.CASCADE, null=True, blank=True)
|
Mtask, verbose_name='关联任务', on_delete=models.CASCADE, null=True, blank=True)
|
||||||
mgroup = models.ForeignKey(
|
mgroup = models.ForeignKey(
|
||||||
Mgroup, verbose_name='工段', on_delete=models.CASCADE, null=True, blank=True)
|
Mgroup, verbose_name='工段', on_delete=models.CASCADE, null=True, blank=True)
|
||||||
|
material_in = models.ForeignKey(
|
||||||
|
Material, verbose_name='消耗物', on_delete=models.CASCADE, null=True, blank=True, related_name='mlog_material_in')
|
||||||
material_out = models.ForeignKey(
|
material_out = models.ForeignKey(
|
||||||
Material, verbose_name='产物', on_delete=models.CASCADE, null=True, blank=True, related_name='mlog_material_out')
|
Material, verbose_name='产物', on_delete=models.CASCADE, null=True, blank=True, related_name='mlog_material_out')
|
||||||
equipment = models.ForeignKey(
|
equipment = models.ForeignKey(
|
||||||
|
|
|
@ -124,12 +124,13 @@ class MlogSerializer(CustomModelSerializer):
|
||||||
['submit_time', 'submit_user', 'material_outs']
|
['submit_time', 'submit_user', 'material_outs']
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
mtask = validated_data.get('mtask', None)
|
mtask: Mtask = validated_data.get('mtask', None)
|
||||||
batch = validated_data['batch']
|
batch = validated_data['batch']
|
||||||
handle_date = validated_data['handle_date']
|
handle_date = validated_data['handle_date']
|
||||||
handle_user = validated_data['handle_user']
|
handle_user = validated_data['handle_user']
|
||||||
if mtask:
|
if mtask:
|
||||||
validated_data['mgroup'] = mtask.mgroup
|
validated_data['mgroup'] = mtask.mgroup
|
||||||
|
validated_data['material_in'] = mtask.material_in
|
||||||
material_out = mtask.material_out
|
material_out = mtask.material_out
|
||||||
validated_data['material_out'] = material_out
|
validated_data['material_out'] = material_out
|
||||||
# if not WMaterial.objects.filter(batch=batch).exists():
|
# if not WMaterial.objects.filter(batch=batch).exists():
|
||||||
|
|
|
@ -11,7 +11,7 @@ from rest_framework.exceptions import ParseError
|
||||||
from apps.system.models import User
|
from apps.system.models import User
|
||||||
from apps.inm.models import MIO, MIOItem, MIOItemA
|
from apps.inm.models import MIO, MIOItem, MIOItemA
|
||||||
from apps.pm.models import Mtask
|
from apps.pm.models import Mtask
|
||||||
from apps.mtm.models import Mgroup, Shift, Material
|
from apps.mtm.models import Mgroup, Shift, Material, Route
|
||||||
|
|
||||||
from .models import SfLog, SfLogExp, WMaterial, Mlog, Mlogb, Handover
|
from .models import SfLog, SfLogExp, WMaterial, Mlog, Mlogb, Handover
|
||||||
|
|
||||||
|
@ -126,10 +126,9 @@ def mlog_submit(mlog: Mlog, user: User, now: Union[datetime.datetime, None]):
|
||||||
return
|
return
|
||||||
if now is None:
|
if now is None:
|
||||||
now = timezone.now()
|
now = timezone.now()
|
||||||
mtask = mlog.mtask
|
belong_dept = mlog.mgroup.belong_dept
|
||||||
belong_dept = mtask.mgroup.belong_dept
|
material_out = mlog.material_out
|
||||||
material_out = mtask.material_out
|
material_in = mlog.material_in
|
||||||
material_in = mtask.material_in
|
|
||||||
if material_in and material_in.is_hidden is False: # 需要进行车间库存管理
|
if material_in and material_in.is_hidden is False: # 需要进行车间库存管理
|
||||||
# 需要判断领用数是否合理
|
# 需要判断领用数是否合理
|
||||||
material_has_qs = WMaterial.objects.filter(
|
material_has_qs = WMaterial.objects.filter(
|
||||||
|
|
Loading…
Reference in New Issue