summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-12-01 14:58:30 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-12-01 14:58:30 +0700
commitaecb9ccda8bd32d4ecfaa0e28e6ed5aaa308a708 (patch)
tree5ba65f57bfb3a7ced62da964b3eb8e454397b53b
parent0614de683d5e0d5c5c98df2d978dc5b19d6d21e3 (diff)
push
-rw-r--r--fixco_custom/models/shipment_group.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/fixco_custom/models/shipment_group.py b/fixco_custom/models/shipment_group.py
index 766bd75..b69d932 100644
--- a/fixco_custom/models/shipment_group.py
+++ b/fixco_custom/models/shipment_group.py
@@ -195,19 +195,24 @@ class PickingLine(models.Model):
for line in self:
scan = (line.scan_receipt or "").strip()
if not scan:
- return
+ continue
- # Cek dari database (aman dari NewId)
- duplicate = self.env['picking.line'].search([
- ('shipment_id', '=', line.shipment_id.id),
- ('scan_receipt', '=', scan),
- ('id', '!=', line.id or 0), # exclude diri sendiri kalau sudah ada ID
- ], limit=1)
+ mem_dupes = line.shipment_id.picking_lines.filtered(
+ lambda l: l.scan_receipt == scan and l != line
+ )
+ if mem_dupes and 'virtual' not in mem_dupes.id.ref:
+ raise UserError("Receipt '%s' already exists in this form." % scan)
+
+ if line.shipment_id.id:
+ db_dupes = self.env['picking.line'].search([
+ ('shipment_id', '=', line.shipment_id.id),
+ ('scan_receipt', '=', scan),
+ ('id', '!=', line.id or 0),
+ ], limit=1)
- if duplicate:
- raise UserError("Receipt '%s' already exists." % scan)
+ if db_dupes:
+ raise UserError("Receipt '%s' already exists in database." % scan)
- # Ambil picking by tracking number
picking = self.env['stock.picking'].search([
('tracking_number', '=', scan)
], limit=1)
@@ -220,7 +225,6 @@ class PickingLine(models.Model):
line.order_reference = picking.order_reference
line.invoice_marketplace = picking.invoice_mp
-
class ProductShipmentLine(models.Model):
_name = 'product.shipment.line'
_description = 'Product Shipment Line'