feat: 添加wamterial ava_qs方法
This commit is contained in:
parent
c69c33e85a
commit
1d778dbdf0
|
@ -42,7 +42,7 @@ class WMaterialFilter(filters.FilterSet):
|
||||||
material__process__exclude = filters.CharFilter(field_name="material__process", lookup_expr="exact", exclude=True)
|
material__process__exclude = filters.CharFilter(field_name="material__process", lookup_expr="exact", exclude=True)
|
||||||
|
|
||||||
def filter_mgroupx(self, queryset, name, value):
|
def filter_mgroupx(self, queryset, name, value):
|
||||||
return queryset.filter(mgroup__id=value)|queryset.filter(belong_dept=Mgroup.objects.get(id=value).belong_dept, mgroup=None)|queryset.filter(mgroup=None, belong_dept=None)
|
return WMaterial.ava_qs(mgroup=Mgroup.objects.get(id=value), qs=queryset)
|
||||||
|
|
||||||
def filter_tag(self, queryset, name, value):
|
def filter_tag(self, queryset, name, value):
|
||||||
mgroupId = self.data.get("mgroup", None)
|
mgroupId = self.data.get("mgroup", None)
|
||||||
|
|
|
@ -130,6 +130,15 @@ class WMaterial(CommonBDModel):
|
||||||
def count_handovering(self):
|
def count_handovering(self):
|
||||||
return Handoverb.objects.filter(wm=self, handover__submit_time__isnull=True).aggregate(count=Sum('count'))['count'] or 0
|
return Handoverb.objects.filter(wm=self, handover__submit_time__isnull=True).aggregate(count=Sum('count'))['count'] or 0
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def ava_qs(cls, mgroup:Mgroup, qs=None):
|
||||||
|
"""
|
||||||
|
可用的queryset
|
||||||
|
"""
|
||||||
|
if qs is None:
|
||||||
|
qs = cls.objects
|
||||||
|
return qs.filter(Q(mgroup=mgroup)|Q(mgroup=None, belong_dept=mgroup.belong_dept)|Q(mgroup=None, belong_dept=None))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def mat_in_qs(cls, mtask: Mtask, qs=None):
|
def mat_in_qs(cls, mtask: Mtask, qs=None):
|
||||||
"""
|
"""
|
||||||
|
@ -137,7 +146,7 @@ class WMaterial(CommonBDModel):
|
||||||
"""
|
"""
|
||||||
if qs is None:
|
if qs is None:
|
||||||
qs = cls.objects
|
qs = cls.objects
|
||||||
return qs.filter(
|
return WMaterial.ava_qs(mgroup=mtask.mgroup, qs=qs).filter(
|
||||||
mgroup=mtask.mgroup,
|
mgroup=mtask.mgroup,
|
||||||
material=mtask.material_in,
|
material=mtask.material_in,
|
||||||
batch__in=Subquery(
|
batch__in=Subquery(
|
||||||
|
|
Loading…
Reference in New Issue