forked from erp-dev/erp
feat: added print_count api, added merchant setting model, added manual mode setting for purchase order
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.2.7 on 2025-11-27 10:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('printing', '0017_alter_plateorder_image_name'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='plateorder',
|
||||
name='plate_image',
|
||||
field=models.JSONField(blank=True, default=dict, help_text='存储多个开版图片的路径,格式: {"image_1": "/path/to/image1.jpg", "image_2": "/path/to/image2.jpg"}', verbose_name='开版图集合'),
|
||||
),
|
||||
]
|
||||
69
printing/migrations/0019_alter_plateorder_plate_image.py
Normal file
69
printing/migrations/0019_alter_plateorder_plate_image.py
Normal file
@@ -0,0 +1,69 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def _build_entry(value, name_hint=''):
|
||||
if not value:
|
||||
return None
|
||||
if isinstance(value, dict):
|
||||
entry = {}
|
||||
entry.update(value)
|
||||
# Ensure keys exist
|
||||
entry.setdefault('name', name_hint or entry.get('name') or '')
|
||||
if 'url' not in entry and 'path' in entry:
|
||||
entry['url'] = entry['path']
|
||||
elif 'path' not in entry and 'url' in entry:
|
||||
entry['path'] = entry['url']
|
||||
return entry
|
||||
if isinstance(value, str):
|
||||
return {
|
||||
'name': name_hint or value.split('/')[-1],
|
||||
'path': value,
|
||||
'url': value,
|
||||
}
|
||||
return None
|
||||
|
||||
|
||||
def forwards(apps, schema_editor):
|
||||
PlateOrder = apps.get_model('printing', 'PlateOrder')
|
||||
for obj in PlateOrder.objects.all():
|
||||
raw = obj.plate_image
|
||||
if not raw:
|
||||
obj.plate_image = []
|
||||
obj.save(update_fields=['plate_image'])
|
||||
continue
|
||||
|
||||
normalized = []
|
||||
if isinstance(raw, list):
|
||||
for entry in raw:
|
||||
built = _build_entry(entry)
|
||||
if built:
|
||||
normalized.append(built)
|
||||
elif isinstance(raw, dict):
|
||||
for key, value in raw.items():
|
||||
built = _build_entry(value, name_hint=str(key))
|
||||
if built:
|
||||
normalized.append(built)
|
||||
else:
|
||||
built = _build_entry(raw)
|
||||
if built:
|
||||
normalized.append(built)
|
||||
|
||||
obj.plate_image = normalized
|
||||
obj.save(update_fields=['plate_image'])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('printing', '0018_plateorder_plate_image_to_jsonfield'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='plateorder',
|
||||
name='plate_image',
|
||||
field=models.JSONField(blank=True, default=list, help_text='存储多个开版图片引用信息,例如 [{"file_id": 1, "name": "封面", "path": "/media/xxx"}]', verbose_name='开版图'),
|
||||
),
|
||||
migrations.RunPython(forwards, migrations.RunPython.noop),
|
||||
]
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.2.7 on 2025-11-28 02:57
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('printing', '0019_alter_plateorder_plate_image'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='plateorder',
|
||||
name='required_completion_date',
|
||||
field=models.DateTimeField(blank=True, null=True, verbose_name='要求完成时间'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 5.2.7 on 2025-11-28 03:29
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('printing', '0020_alter_plateorder_required_completion_date'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='plateorder',
|
||||
name='print_count',
|
||||
field=models.PositiveIntegerField(default=0, verbose_name='打印次数'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='printingorder',
|
||||
name='print_count',
|
||||
field=models.PositiveIntegerField(default=0, verbose_name='打印次数'),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user