1
0
forked from erp-dev/erp

feat: hpname and external_order_id + product_name unique together

This commit is contained in:
2026-03-23 19:06:11 +08:00
parent b58667ca52
commit eb5fae1ce7
6 changed files with 251 additions and 10 deletions

View File

@@ -500,12 +500,13 @@ def _build_external_order_data(
return {
'merchant': merchant,
'customer': customer,
'fabric': '',
'fabric': str(first.get('HpName') or '').strip(),
'width': str(first.get('SeHao') or '').strip(),
'fabric_source': fabric_source or None,
'craft': craft or None,
'rolling_warn': str(first.get('BeiZhu') or '').strip() or None,
'curve': str(first.get('MeoA') or '').strip() or None,
'position': str(first.get('FidJ') or '').strip() or None,
'outgoing_date': _parse_external_datetime(first.get('KdRiQi')),
'created_by': created_by_user,
'external_order_id': external_order_id,
@@ -547,6 +548,7 @@ def _upsert_external_printing_order(*, merchant, external_order_id: str, group_r
def _upsert_external_printing_job(*, merchant, printing_order, record: dict, sync_user, category):
record_id = _extract_positive_int(record.get('ID'), field_name='ID', allow_blank=False)
external_product_name = str(record.get('YanSe') or '').strip()
created_by_user, _external_employee_name = _resolve_external_employee_user(
merchant=merchant,
external_employee_name=str(record.get('CaoZY') or '').strip(),
@@ -554,7 +556,7 @@ def _upsert_external_printing_job(*, merchant, printing_order, record: dict, syn
)
product, _ = _ensure_external_product(
merchant=merchant,
external_product_name=str(record.get('YanSe') or '').strip(),
external_product_name=external_product_name,
category=category,
)
job_data = {
@@ -574,7 +576,7 @@ def _upsert_external_printing_job(*, merchant, printing_order, record: dict, syn
existing_job = (
printing_models.PrintingJob.objects.filter(
printing_order=printing_order,
original_id=record_id,
product=product,
)
.order_by('id')
.first()