forked from erp-dev/erp
feat: added plate order clone
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from django.contrib import admin
|
||||
from django.contrib.admin import action
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.forms import BaseInlineFormSet
|
||||
from django.utils.html import format_html
|
||||
from . import models
|
||||
@@ -195,6 +196,7 @@ class PrintingOrderAdmin(admin.ModelAdmin):
|
||||
# 为所有新创建且没有 business_object 的 job 创建 BusinessObject
|
||||
if isinstance(formset.model, type) and issubclass(formset.model, models.PrintingJob):
|
||||
order = form.instance
|
||||
ct = ContentType.objects.get_for_model(models.PrintingJob)
|
||||
for job in order.printing_jobs.all():
|
||||
if not job.business_object and order.process:
|
||||
from stateflow.models import BusinessObject
|
||||
@@ -202,6 +204,8 @@ class PrintingOrderAdmin(admin.ModelAdmin):
|
||||
name=f"PrintingJob-{job.id}",
|
||||
process=order.process,
|
||||
description=f"印染任务 {job.id} 的流程实例",
|
||||
content_type=ct,
|
||||
object_id=job.id,
|
||||
)
|
||||
job.business_object = business_object
|
||||
job.save(update_fields=['business_object'])
|
||||
|
||||
Reference in New Issue
Block a user