主产出只能有1个
This commit is contained in:
parent
b5497a6b75
commit
b40efc3ca6
|
@ -177,6 +177,7 @@ class OutputMaterial(CommonAModel):
|
||||||
输出物料
|
输出物料
|
||||||
"""
|
"""
|
||||||
material = models.ForeignKey(Material, verbose_name='输出物料', on_delete=models.CASCADE, related_name='outputmaterial')
|
material = models.ForeignKey(Material, verbose_name='输出物料', on_delete=models.CASCADE, related_name='outputmaterial')
|
||||||
|
is_main = models.BooleanField('是否主产出', default=True) # 以该产品完成度计算进度
|
||||||
count = models.FloatField('产出量', default=1)
|
count = models.FloatField('产出量', default=1)
|
||||||
subproduction = models.ForeignKey(SubProduction, verbose_name='关联生产分解', on_delete=models.CASCADE)
|
subproduction = models.ForeignKey(SubProduction, verbose_name='关联生产分解', on_delete=models.CASCADE)
|
||||||
sort = models.IntegerField('排序号', default=1)
|
sort = models.IntegerField('排序号', default=1)
|
||||||
|
|
|
@ -101,6 +101,8 @@ class OutputMaterialSerializer(serializers.ModelSerializer):
|
||||||
fields = ['count', 'sort', 'material', 'subproduction']
|
fields = ['count', 'sort', 'material', 'subproduction']
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
|
if OutputMaterial.objects.filter(subproduction=validated_data['subproduction'], is_deleted=False, is_main=True).exists():
|
||||||
|
raise ValidationError('主产出只能有1个')
|
||||||
if OutputMaterial.objects.filter(material=validated_data['material'], subproduction=validated_data['subproduction'], is_deleted=False).exists():
|
if OutputMaterial.objects.filter(material=validated_data['material'], subproduction=validated_data['subproduction'], is_deleted=False).exists():
|
||||||
raise ValidationError('该物料已存在')
|
raise ValidationError('该物料已存在')
|
||||||
return super().create(validated_data)
|
return super().create(validated_data)
|
||||||
|
|
|
@ -7,6 +7,16 @@ from utils.model import SoftModel, BaseModel
|
||||||
from simple_history.models import HistoricalRecords
|
from simple_history.models import HistoricalRecords
|
||||||
|
|
||||||
|
|
||||||
|
class Good(CommonAModel):
|
||||||
|
"""
|
||||||
|
物品
|
||||||
|
"""
|
||||||
|
number = models.CharField('物品编号', primary_key=True, null=True, blank=True, max_length=50)
|
||||||
|
m_state = models.ForeignKey('所属物料状态', on_delete=models.CASCADE)
|
||||||
|
p_state = models.ForeignKey('所在步骤', )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Vendor(CommonAModel):
|
class Vendor(CommonAModel):
|
||||||
"""
|
"""
|
||||||
供应商信息
|
供应商信息
|
||||||
|
|
|
@ -55,7 +55,8 @@ INSTALLED_APPS = [
|
||||||
'apps.inm',
|
'apps.inm',
|
||||||
'apps.sam',
|
'apps.sam',
|
||||||
'apps.qm',
|
'apps.qm',
|
||||||
'apps.pm'
|
'apps.pm',
|
||||||
|
# 'apps.wpm'
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|
Loading…
Reference in New Issue