1
0
forked from erp-dev/erp
This commit is contained in:
2026-07-02 18:26:09 +08:00
parent 5170700234
commit 4538e51ad5
14 changed files with 471 additions and 26 deletions

View File

@@ -366,3 +366,82 @@ class MesServiceTestCase(TestCase):
operator=self.operator,
status=ProductionAssignmentStatusEnum.CANCELLED,
)
def test_create_production_assignment_without_device(self):
customer = Customer.objects.create(
merchant=self.merchant,
name='无设备客户',
mobile='13800138002',
)
printing_order = PrintingOrder.objects.create(
merchant=self.merchant,
customer=customer,
fabric='无设备面料',
width='150cm',
created_by=self.user,
)
content_type = ContentType.objects.get_for_model(PrintingOrder)
assignment = services.create_production_assignment(
merchant=self.merchant,
device=None,
content_type=content_type,
object_id=printing_order.id,
assigner=self.operator,
production_quantity=100,
created_by=self.user,
operator=self.operator,
)
self.assertIsNone(assignment.device)
self.assertIsNone(assignment.device_id)
self.assertEqual(assignment.status, ProductionAssignmentStatusEnum.DRAFT)
self.assertEqual(assignment.production_quantity, 100)
def test_update_production_assignment_clear_device(self):
customer = Customer.objects.create(
merchant=self.merchant,
name='清空设备客户',
mobile='13800138003',
)
printing_order = PrintingOrder.objects.create(
merchant=self.merchant,
customer=customer,
fabric='清空设备面料',
width='150cm',
created_by=self.user,
)
category = services.create_device_category(
merchant=self.merchant,
name='打印机',
created_by=self.user,
operator=self.operator,
)
device = services.create_device(
merchant=self.merchant,
category=category,
name='设备A',
created_by=self.user,
operator=self.operator,
peak_capacity=120,
)
content_type = ContentType.objects.get_for_model(PrintingOrder)
assignment = services.create_production_assignment(
merchant=self.merchant,
device=device,
content_type=content_type,
object_id=printing_order.id,
assigner=self.operator,
production_quantity=200,
created_by=self.user,
operator=self.operator,
)
self.assertIsNotNone(assignment.device)
updated = services.update_production_assignment(
assignment=assignment,
operator=self.operator,
device=None,
)
self.assertIsNone(updated.device)
self.assertIsNone(updated.device_id)