feat: 增加周预估消耗量字段

This commit is contained in:
caoqianming 2024-03-20 17:39:44 +08:00
parent fd8040b20e
commit 6e4298873f
3 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2.12 on 2024-03-20 09:35
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mtm', '0025_auto_20231120_1139'),
]
operations = [
migrations.AddField(
model_name='material',
name='week_esitimate_consume',
field=models.PositiveIntegerField(blank=True, null=True, verbose_name='周消耗预估'),
),
]

View File

@ -57,6 +57,8 @@ class Material(CommonAModel):
unit = models.CharField('基准计量单位', default='', max_length=10)
count = models.PositiveIntegerField('物料库存总数', default=0)
count_safe = models.PositiveIntegerField('安全库存总数', null=True, blank=True)
week_esitimate_consume = models.PositiveIntegerField(
'周消耗预估', null=True, blank=True)
process = models.ForeignKey(
Process, verbose_name='所用工序', on_delete=models.CASCADE, null=True, blank=True)
parent = models.ForeignKey(

View File

@ -44,6 +44,19 @@ class MaterialViewSet(CustomModelViewSet):
daoru_material(settings.BASE_DIR + request.data.get('path', ''))
return Response()
@action(methods=['put'], detail=True, serializer_class=Serializer, perms_map={'put': '*'})
@transaction.atomic
def set_week_esitimate_consume(self, request, *args, **kwargs):
"""设置周预估消耗量
设置周预估消耗量
"""
obj: Material = self.get_object()
obj.week_esitimate_consume = request.data.get(
'week_esitimate_consume', None)
obj.save()
return Response()
class ShiftViewSet(ListModelMixin, CustomGenericViewSet):
"""