1
0
forked from erp-dev/erp

added image_name to PlateOrder model

This commit is contained in:
2025-11-27 15:14:34 +08:00
parent a9c75a13fa
commit 0fa153849c
12 changed files with 108 additions and 432 deletions

View File

@@ -52,7 +52,7 @@ class PlateOrderAdmin(admin.ModelAdmin):
}),
('开版信息', {
'fields': [
'plate_method', 'plate_image', 'plate_notes', 'reprint_reason',
'plate_method', 'plate_image', 'image_name', 'plate_notes', 'reprint_reason',
'is_mark_frame', 'sample_meter', 'required_sample_meters'
]
}),

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.2.7 on 2025-11-27 06:53
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('printing', '0015_plateorder_designer'),
]
operations = [
migrations.AddField(
model_name='plateorder',
name='image_name',
field=models.CharField(blank=True, max_length=100, null=True, verbose_name='图片名称'),
),
]

View File

@@ -16,6 +16,7 @@ class PlateOrder(ModelBase):
plate_date = models.DateTimeField(null=True, blank=True, verbose_name='下版时间')
plate_method = models.CharField(max_length=50, blank=True, null=True, verbose_name='开版方式')
plate_image = models.FileField(upload_to='plate_images/', null=True, blank=True, verbose_name='开版图')
image_name = models.CharField(max_length=100, blank=True, null=True, verbose_name='图片名称')
plate_notes = models.TextField(blank=True, null=True, verbose_name='打版注意事项')
reprint_reason = models.TextField(blank=True, null=True, verbose_name='复版原因')
@@ -113,10 +114,17 @@ class PlateOrder(ModelBase):
"""保存时自动创建 BusinessObject"""
# 先保存以获取 ID如果是新建
is_new = self.pk is None
update_fields = kwargs.get('update_fields')
super().save(*args, **kwargs)
should_auto_create = (
self.process
and not self.business_object
and (is_new or update_fields is None or 'process' in (update_fields or []))
)
# 如果有 process 且没有 business_object则自动创建
if self.process and not self.business_object:
if should_auto_create:
try:
from stateflow.models import Process
process_obj = Process.objects.get(id=self.process)

View File

@@ -717,6 +717,10 @@ components:
format: binary
nullable: true
description: 开版图片(仅 multipart/form-data 时可上传)。
image_name:
type: string
nullable: true
description: 开版图片的名称(可独立填写,便于标注原始文件名)。
plate_notes:
type: string
description: 打版注意事项。