diff options
| author | Mqdd <ahmadmiqdad27@gmail.com> | 2026-01-02 19:04:30 +0700 |
|---|---|---|
| committer | Mqdd <ahmadmiqdad27@gmail.com> | 2026-01-02 19:04:30 +0700 |
| commit | 42ff804b61b635c8be662784d03a7bd8e87b8bbe (patch) | |
| tree | 2b3706490c1cc0b337e96b6d6c10de0be299b42e | |
| parent | 135d9c2643a1f588494cddec7ca4d1fe2165b82d (diff) | |
<MIqdad> fix check duplicate scan
| -rw-r--r-- | fixco_custom/models/shipment_group.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/fixco_custom/models/shipment_group.py b/fixco_custom/models/shipment_group.py index b4ed27b..2663cd9 100644 --- a/fixco_custom/models/shipment_group.py +++ b/fixco_custom/models/shipment_group.py @@ -215,9 +215,22 @@ class PickingLine(models.Model): # ('id', '!=', line.id) ], limit=1) - if not dup: + dup2 = self.search([ + ('scan_receipt', '=', line.invoice_marketplace), + # ('id', '!=', line.id) + ], limit=1) + + if not (dup or dup2): continue + if dup: + raise ValidationError( + "Receipt '%s' sudah digunakan di Shipment %s." % + (line.scan_receipt, dup.shipment_id.number or '-') + ) + else: + raise UserError("Invoice Marketplace sudah digunakan") + # 1. Dup di shipment yang sama (lagi create / edit) # if dup.shipment_id.id == line.shipment_id.id: # raise ValidationError( @@ -226,10 +239,6 @@ class PickingLine(models.Model): # ) # 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') |
