fix: 去除materialbatch的数据库约束

This commit is contained in:
caoqianming 2025-02-21 17:23:28 +08:00
parent a1525d1289
commit af999467db
3 changed files with 18 additions and 4 deletions

View File

@ -0,0 +1,17 @@
# Generated by Django 3.2.12 on 2025-02-21 09:23
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('inm', '0026_mioitemw_ftest'),
]
operations = [
migrations.AlterUniqueTogether(
name='materialbatch',
unique_together=set(),
),
]

View File

@ -36,9 +36,6 @@ class MaterialBatch(BaseModel):
material_ofrom = models.ForeignKey(Material, verbose_name='原料物料', on_delete=models.SET_NULL, null=True, blank=True, related_name='mb_mofrom')
defect = models.ForeignKey('qm.defect', verbose_name='缺陷', on_delete=models.PROTECT, null=True, blank=True)
class Meta:
unique_together = ('material', 'batch', 'warehouse')
class MaterialBatchA(BaseModel):
"""

View File

@ -325,7 +325,7 @@ class InmService:
state = WMaterial.WM_OK
if defect:
state = WMaterial.WM_NOTOK
mb, _ = MaterialBatch.safe_get_or_create(
mb, _ = MaterialBatch.objects.get_or_create(
material=material,
warehouse=warehouse,
batch=batch,