forked from erp-dev/erp
feat: added some filed to shipment serializers
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('shipment', '0022_shipment_rejected_sales_item_ids'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='shipmentdelivery',
|
||||
name='shipment_order_ids',
|
||||
field=models.JSONField(blank=True, default=list, help_text='前端自管的出货单展示顺序,后端不据此重排 shipments 关系', null=True, verbose_name='出货单顺序ID列表'),
|
||||
),
|
||||
]
|
||||
@@ -561,6 +561,14 @@ class ShipmentDelivery(ModelBase):
|
||||
verbose_name='内部备注',
|
||||
)
|
||||
|
||||
shipment_order_ids = models.JSONField(
|
||||
null=True,
|
||||
blank=True,
|
||||
default=list,
|
||||
verbose_name='出货单顺序ID列表',
|
||||
help_text='前端自管的出货单展示顺序,后端不据此重排 shipments 关系',
|
||||
)
|
||||
|
||||
started_at = models.DateTimeField(
|
||||
null=True,
|
||||
blank=True,
|
||||
|
||||
@@ -28,6 +28,9 @@ from shipment.models import (
|
||||
from shipment.signals import shipment_created
|
||||
|
||||
|
||||
UNSET = object()
|
||||
|
||||
|
||||
def _resolve_user_merchant(user):
|
||||
emp = getattr(user, "employee", None)
|
||||
return getattr(emp, "merchant", None) if emp else None
|
||||
@@ -405,6 +408,7 @@ def create_shipment_delivery(
|
||||
contact_phone: str = "",
|
||||
vehicle_capacity: str = "",
|
||||
shipment_ids: list[int],
|
||||
shipment_order_ids: list | None = None,
|
||||
created_by,
|
||||
remark: str = "",
|
||||
internal_remark: str = "",
|
||||
@@ -434,6 +438,7 @@ def create_shipment_delivery(
|
||||
vehicle_capacity=(vehicle_capacity or "").strip(),
|
||||
remark=(remark or "").strip(),
|
||||
internal_remark=(internal_remark or "").strip(),
|
||||
shipment_order_ids=shipment_order_ids,
|
||||
created_by=created_by,
|
||||
operator=operator,
|
||||
)
|
||||
@@ -453,6 +458,7 @@ def update_shipment_delivery(
|
||||
contact_phone: str | None = None,
|
||||
vehicle_capacity: str | None = None,
|
||||
shipment_ids: list[int] | None = None,
|
||||
shipment_order_ids=UNSET,
|
||||
remark: str | None = None,
|
||||
internal_remark: str | None = None,
|
||||
operator=None,
|
||||
@@ -481,6 +487,9 @@ def update_shipment_delivery(
|
||||
if internal_remark is not None:
|
||||
delivery.internal_remark = (internal_remark or "").strip()
|
||||
|
||||
if shipment_order_ids is not UNSET:
|
||||
delivery.shipment_order_ids = shipment_order_ids
|
||||
|
||||
if shipment_ids is not None:
|
||||
shipments = _resolve_delivery_shipments(
|
||||
shipment_ids=shipment_ids,
|
||||
|
||||
Reference in New Issue
Block a user