出入库记录审核人
This commit is contained in:
parent
487c8fac28
commit
206df9c85c
|
|
@ -0,0 +1,25 @@
|
|||
# Generated by Django 3.2.6 on 2021-11-11 01:40
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('inm', '0014_auto_20211111_0918'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='fifo',
|
||||
name='operator',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='fifo',
|
||||
name='auditor',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='审核人'),
|
||||
),
|
||||
]
|
||||
|
|
@ -66,7 +66,7 @@ class FIFO(CommonAModel):
|
|||
)
|
||||
type = models.IntegerField('出入库类型', default=1)
|
||||
is_audited = models.BooleanField('是否审核', default=False)
|
||||
operator = models.ForeignKey(User, verbose_name='操作人', on_delete=models.CASCADE)
|
||||
auditor = models.ForeignKey(User, verbose_name='审核人', on_delete=models.CASCADE, null=True, blank=True)
|
||||
subproduction_plan = models.ForeignKey(SubProductionPlan, verbose_name='关联子生产计划', on_delete=models.DO_NOTHING, null=True, blank=True)
|
||||
inout_date = models.DateField('出入库日期')
|
||||
remark = models.CharField('备注', max_length=1000, default='')
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ class MaterialBatchSerializer(serializers. ModelSerializer):
|
|||
fields = '__all__'
|
||||
|
||||
class FIFOListSerializer(serializers.ModelSerializer):
|
||||
operator_ = UserSimpleSerializer(source='operator', read_only=True)
|
||||
auditor_ = UserSimpleSerializer(source='auditor', read_only=True)
|
||||
create_by_ = UserSimpleSerializer(source='create_by', read_only=True)
|
||||
class Meta:
|
||||
model=FIFO
|
||||
fields = '__all__'
|
||||
|
|
@ -72,7 +73,7 @@ class FIFOInPurSerializer(serializers.ModelSerializer):
|
|||
details = FIFODetailInPurSerializer(many=True)
|
||||
class Meta:
|
||||
model = FIFO
|
||||
fields = ['operator', 'details', 'inout_date']
|
||||
fields = ['details', 'inout_date']
|
||||
|
||||
def create(self, validated_data):
|
||||
details = validated_data.pop('details')
|
||||
|
|
|
|||
|
|
@ -86,11 +86,11 @@ class FIFOViewSet(ListModelMixin, GenericViewSet):
|
|||
出入库记录
|
||||
"""
|
||||
perms_map = {'*': '*'}
|
||||
queryset = FIFO.objects.select_related('warehouse', 'operator')
|
||||
queryset = FIFO.objects.select_related('auditor', 'create_by')
|
||||
serializer_class = FIFOListSerializer
|
||||
filterset_fields = '__all__'
|
||||
ordering_fields = '__all__'
|
||||
search_fields = ['warehouse__name', 'warehouse__number']
|
||||
search_fields = []
|
||||
ordering = ['-pk']
|
||||
|
||||
def get_serializer_class(self):
|
||||
|
|
@ -121,6 +121,7 @@ class FIFOViewSet(ListModelMixin, GenericViewSet):
|
|||
raise APIException('该入库记录已审核通过')
|
||||
with transaction.atomic():
|
||||
obj.is_audited = True
|
||||
obj.auditor = request.user
|
||||
obj.save()
|
||||
update_inm(obj) # 更新库存
|
||||
return Response()
|
||||
|
|
|
|||
|
|
@ -38,9 +38,7 @@ class PickSerializer(serializers.Serializer):
|
|||
raise serializers.ValidationError('物料不存在')
|
||||
# 创建出库记录
|
||||
with transaction.atomic():
|
||||
operator = self.context['request'].user
|
||||
validated_data['create_by'] = operator
|
||||
validated_data['operator'] = operator
|
||||
validated_data['create_by'] = self.context['request'].user
|
||||
validated_data['type'] = FIFO.FIFO_TYPE_DO_OUT
|
||||
validated_data['inout_date'] = timezone.now()
|
||||
fifo = FIFO.objects.create(**validated_data)
|
||||
|
|
|
|||
Loading…
Reference in New Issue