summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-12-01 15:14:28 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-12-01 15:14:28 +0700
commit7714943d84b320e27223aaac563a86c244580412 (patch)
treee83194efb1ee80d6e3fc27e264b7209d60d5e2cb
parentaecb9ccda8bd32d4ecfaa0e28e6ed5aaa308a708 (diff)
push
-rw-r--r--fixco_custom/models/shipment_group.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/fixco_custom/models/shipment_group.py b/fixco_custom/models/shipment_group.py
index b69d932..b427bcd 100644
--- a/fixco_custom/models/shipment_group.py
+++ b/fixco_custom/models/shipment_group.py
@@ -197,22 +197,27 @@ class PickingLine(models.Model):
if not scan:
continue
+ # === 1. Cek duplikat di memory (record yang belum save) ===
mem_dupes = line.shipment_id.picking_lines.filtered(
- lambda l: l.scan_receipt == scan and l != line
+ lambda l: l is not line and
+ (l.id.ref == None) and
+ l.scan_receipt == scan and not self
)
- if mem_dupes and 'virtual' not in mem_dupes.id.ref:
- raise UserError("Receipt '%s' already exists in this form." % scan)
+ if mem_dupes:
+ raise UserError("Receipt '%s' already exists (unsaved)." % scan)
+ # === 2. Cek duplikat di database ===
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),
+ ('id', '!=', line._origin.id or 0),
], limit=1)
if db_dupes:
- raise UserError("Receipt '%s' already exists in database." % scan)
+ raise UserError("Receipt '%s' already exists." % scan)
+ # === 3. Cek tracking number di stock.picking ===
picking = self.env['stock.picking'].search([
('tracking_number', '=', scan)
], limit=1)
@@ -225,6 +230,7 @@ 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'