Merge branch 'develop' of https://e.coding.net/ctcdevteam/hberp/hberp into develop
This commit is contained in:
commit
2e5b24b370
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.9 on 2022-06-06 05:15
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('mtm', '0051_material_file'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='material',
|
||||
name='brand',
|
||||
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='牌号'),
|
||||
),
|
||||
]
|
|
@ -36,6 +36,7 @@ class Material(CommonAModel):
|
|||
)
|
||||
name = models.CharField('物料名称', max_length=100)
|
||||
number = models.CharField('编号', max_length=100, unique=True)
|
||||
brand = models.CharField('牌号', max_length=100, null=True, blank=True)
|
||||
specification = models.CharField('型号', max_length=100, null=True, blank=True)
|
||||
type = models.PositiveSmallIntegerField('物料类型', choices= type_choices, default=1)
|
||||
sort_str = models.CharField('排序字符', max_length=100, null=True, blank=True)
|
||||
|
|
|
@ -46,7 +46,7 @@ class PackItemUpdateSerializer(serializers.ModelSerializer):
|
|||
class MaterialSimpleSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Material
|
||||
fields = ['id', 'name', 'number', 'unit','specification', 'type', 'count', 'count_safe']
|
||||
fields = ['id', 'name', 'number', 'unit','specification', 'type', 'count', 'count_safe', 'brand']
|
||||
|
||||
class PackItemDetailSerializer(serializers.ModelSerializer):
|
||||
material_ = MaterialSimpleSerializer(source='material', read_only=True)
|
||||
|
@ -227,7 +227,7 @@ class RecordFormCreateSerializer(serializers.ModelSerializer):
|
|||
class RecordFormUpdateSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = RecordForm
|
||||
fields = ['name', 'type', 'number', 'enabled', 'export_template', 'material']
|
||||
fields = ['name', 'type', 'number', 'enabled', 'export_template', 'material', 'form']
|
||||
|
||||
# def validate(self, attrs):
|
||||
# if attrs['enabled']:
|
||||
|
@ -280,7 +280,7 @@ class RecordFormFieldCreateSerializer(serializers.ModelSerializer):
|
|||
class RecordFormFieldUpdateSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = RecordFormField
|
||||
exclude = ['field_key']
|
||||
fields = '__all__'
|
||||
|
||||
class RecordFormFieldSimpleSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
|
|
|
@ -184,7 +184,7 @@ class RecordFormViewSet(OptimizationMixin, CreateUpdateModelAMixin, ModelViewSet
|
|||
queryset = RecordForm.objects.all()
|
||||
filterset_fields = ['step', 'type', 'material', 'number', 'enabled']
|
||||
search_fields = ['name']
|
||||
ordering='id'
|
||||
ordering=['id']
|
||||
|
||||
|
||||
def get_serializer_class(self):
|
||||
|
@ -234,8 +234,8 @@ class RecordFormFieldViewSet(OptimizationMixin, CreateUpdateModelAMixin, ModelVi
|
|||
queryset = RecordFormField.objects.all()
|
||||
filterset_fields = ['field_type', 'form']
|
||||
search_fields = ['field_name', 'field_key']
|
||||
ordering = 'sort'
|
||||
ordering_fields = ['sort', 'id']
|
||||
ordering = ['sort', 'create_time']
|
||||
ordering_fields = ['sort', 'create_time']
|
||||
|
||||
def get_serializer_class(self):
|
||||
if self.action =='create':
|
||||
|
|
|
@ -8,7 +8,7 @@ from apps.inm.serializers import WareHouseSimpleSerializer
|
|||
from apps.inm.services import InmService
|
||||
from apps.mtm.models import Material, RecordForm, RecordFormField, Step, SubprodctionMaterial
|
||||
from apps.mtm.serializers import MaterialSimpleSerializer, ProcessSimpleSerializer, RecordFormSimpleSerializer, StepSimpleSerializer
|
||||
from django.db.models.aggregates import Sum
|
||||
from django.db.models.aggregates import Sum, Count
|
||||
from apps.pm.models import ProductionPlan, SubProductionPlan, SubProductionProgress
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
@ -282,18 +282,24 @@ class OperationListSerializer(serializers.ModelSerializer):
|
|||
# return WProduct.objects.filter(ow_wproduct__operation=obj).values('id', 'number')
|
||||
|
||||
def get_out_detail(self, obj):
|
||||
qs = OperationMaterial.objects.filter(operation=obj,
|
||||
type=SubprodctionMaterial.SUB_MA_TYPE_OUT, subproduction_progress__is_main=True).values(
|
||||
'subproduction_plan__production_plan',
|
||||
'subproduction_plan__production_plan__product'
|
||||
).annotate(count=Sum('count'))
|
||||
rets = []
|
||||
if obj.step.type == Step.STEP_TYPE_NOM:
|
||||
qs = OperationWproduct.objects.filter(operation=obj).values(
|
||||
'subproduction_plan__production_plan',
|
||||
'subproduction_plan__production_plan__product'
|
||||
).annotate(count=Count('wproduct'))
|
||||
else:
|
||||
qs = OperationMaterial.objects.filter(operation=obj,
|
||||
type=SubprodctionMaterial.SUB_MA_TYPE_OUT, subproduction_progress__is_main=True).values(
|
||||
'subproduction_plan__production_plan',
|
||||
'subproduction_plan__production_plan__product'
|
||||
).annotate(count=Sum('count'))
|
||||
for i in qs:
|
||||
ret = {}
|
||||
ret['plan'] = ProductionPlanSimpleSerializer(instance=ProductionPlan.objects.get(
|
||||
id= i['subproduction_plan__production_plan'])).data
|
||||
id= i['subproduction_plan__production_plan'])).data
|
||||
ret['product'] = MaterialSimpleSerializer(instance=Material.objects.get(
|
||||
id=i['subproduction_plan__production_plan__product'])).data
|
||||
id=i['subproduction_plan__production_plan__product'])).data
|
||||
ret['count'] = i['count']
|
||||
rets.append(ret)
|
||||
return rets
|
||||
|
|
|
@ -605,8 +605,8 @@ class OperationViewSet(ListModelMixin, RetrieveModelMixin, CreateModelMixin, Upd
|
|||
# 查询需要填写的自定义表格
|
||||
forms = RecordForm.objects.filter(
|
||||
step=step, type=RecordForm.RF_TYPE_DO, enabled=True)
|
||||
# 根据产品不同进行筛选
|
||||
if 'wproducts' in vdata:
|
||||
# 根据产品不同进行筛选 这里其实是有问题的,应该是以产出物归属产品来查表,但操作刚创建是没有的,先这样吧
|
||||
if 'wproducts' in vdata and splans:
|
||||
xforms = forms.filter(material=splans[0].production_plan.product)
|
||||
if xforms.exists():
|
||||
forms = xforms
|
||||
|
|
Loading…
Reference in New Issue