summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-12-01 16:28:37 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-12-01 16:28:37 +0700
commita90dd3de9881af1aa1f4e444395bed8f3cac7a8e (patch)
tree02a3d7fe39e9558c58bfc9989f17358940e18a65
parent643ea3d6e49e4a2b26fc76cd3a2de61f27d616f5 (diff)
push
-rw-r--r--fixco_custom/models/shipment_group.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/fixco_custom/models/shipment_group.py b/fixco_custom/models/shipment_group.py
index 2c36ee0..ca3ef76 100644
--- a/fixco_custom/models/shipment_group.py
+++ b/fixco_custom/models/shipment_group.py
@@ -196,18 +196,29 @@ class PickingLine(models.Model):
if not line.scan_receipt:
continue
- # Cari record lain selain dirinya
+ # Cari duplikat selain dirinya
dup = self.search([
('scan_receipt', '=', line.scan_receipt),
('id', '!=', line.id)
], limit=1)
- if dup:
+ if not dup:
+ continue
+
+ # 1. Dup di shipment yang sama (lagi create / edit)
+ if dup.shipment_id.id == line.shipment_id.id:
raise ValidationError(
- "Receipt '%s' already exists in Shipment %s." %
- (line.scan_receipt, dup.shipment_id.number or '-')
+ "Receipt '%s' sudah ada di Shipment ini." %
+ line.scan_receipt
)
+ # 2. Dup di shipment lain (data lama)
+ raise ValidationError(
+ "Receipt '%s' sudah digunakan di Shipment %s." %
+ (line.scan_receipt, dup.shipment_id.number or '-')
+ )
+
+
@api.onchange('scan_receipt')
def _onchange_scan_receipt(self):