feat: wmaterial增加count_working proptey
This commit is contained in:
parent
bc92e90765
commit
7a8bee5e59
|
@ -8,6 +8,7 @@ from apps.em.models import Equipment
|
|||
from apps.system.models import Dept
|
||||
from datetime import timedelta
|
||||
from apps.pum.models import Supplier
|
||||
from django.db.models import Sum
|
||||
|
||||
# Create your models here.
|
||||
|
||||
|
@ -106,6 +107,9 @@ class WMaterial(CommonBDModel):
|
|||
material_origin = models.ForeignKey(Material, verbose_name='原始物料', on_delete=models.SET_NULL, null=True, blank=True, related_name='wm_mo')
|
||||
count_xtest = models.PositiveIntegerField('已检数量', null=True, blank=True)
|
||||
|
||||
@property
|
||||
def count_working(self, obj):
|
||||
return Mlogb.objects.filter(wm_in=obj, mlog__work_end_time__isnull=True).aggregate(count=Sum('count'))['count'] or 0
|
||||
|
||||
class Fmlog(CommonADModel):
|
||||
route = models.ForeignKey(Route, verbose_name='生产路线', on_delete=models.SET_NULL, null=True, blank=True)
|
||||
|
|
|
@ -181,6 +181,7 @@ class WMaterialSerializer(CustomModelSerializer):
|
|||
source='belong_dept.name', read_only=True)
|
||||
material_origin_name = serializers.StringRelatedField(source='material_origin', read_only=True)
|
||||
notok_sign_name = serializers.SerializerMethodField()
|
||||
count_working = serializers.CharField(read_only=True, label='在制数量')
|
||||
|
||||
def get_notok_sign_name(self, obj):
|
||||
return getattr(NotOkOption, obj.notok_sign, NotOkOption.qt).label if obj.notok_sign else None
|
||||
|
|
Loading…
Reference in New Issue