From a90dd3de9881af1aa1f4e444395bed8f3cac7a8e Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Mon, 1 Dec 2025 16:28:37 +0700 Subject: push --- fixco_custom/models/shipment_group.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'fixco_custom') 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): -- cgit v1.2.3