forked from erp-dev/erp
fix: added merchant_id in models of shipment module
This commit is contained in:
@@ -114,8 +114,22 @@ def on_printing_job_process_completed(sender, **kwargs):
|
||||
|
||||
try:
|
||||
with transaction.atomic():
|
||||
# SalesItem.merchant 不允许为空,优先取 printing_job.merchant
|
||||
sales_merchant = getattr(printing_job, 'merchant', None)
|
||||
if not sales_merchant and getattr(printing_job, 'printing_order', None):
|
||||
sales_merchant = getattr(printing_job.printing_order, 'merchant', None)
|
||||
if not sales_merchant and last_completed_by and hasattr(last_completed_by, 'employee'):
|
||||
sales_merchant = getattr(last_completed_by.employee, 'merchant', None)
|
||||
if not sales_merchant:
|
||||
logger.warning(
|
||||
f'PrintingJob #{printing_job.id} 流程完成,'
|
||||
f'但无法确定 merchant,跳过销售品创建'
|
||||
)
|
||||
return
|
||||
|
||||
sales_item = SalesItem.objects.create(
|
||||
shipment=None, # 暂不关联出货单,待后续分配
|
||||
merchant=sales_merchant,
|
||||
name=product_name,
|
||||
quantity=quantity,
|
||||
unit=sales_unit,
|
||||
|
||||
Reference in New Issue
Block a user