summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/partial_delivery.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-11-19 14:49:01 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-11-19 14:49:01 +0700
commitbb2be920076aabc49b4f9fdd896d14e096e633eb (patch)
tree588196ba53fb7e41d96a61272bdb74b4821fe661 /indoteknik_custom/models/partial_delivery.py
parent9c4f131ffaf37ca47a78b320a68f7de4e846ecfb (diff)
parent58623e9509789381dbe334969de647b4ad0302a4 (diff)
Merge branch 'odoo-backup' into locatorlocator
# Conflicts: # indoteknik_custom/models/__init__.py # indoteknik_custom/models/stock_move.py # indoteknik_custom/security/ir.model.access.csv # indoteknik_custom/views/stock_picking.xml
Diffstat (limited to 'indoteknik_custom/models/partial_delivery.py')
-rw-r--r--indoteknik_custom/models/partial_delivery.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/indoteknik_custom/models/partial_delivery.py b/indoteknik_custom/models/partial_delivery.py
index 4df7da1e..519f505c 100644
--- a/indoteknik_custom/models/partial_delivery.py
+++ b/indoteknik_custom/models/partial_delivery.py
@@ -115,9 +115,13 @@ class PartialDeliveryWizard(models.TransientModel):
raise UserError(_("Picking harus dalam status Ready (assigned)."))
lines_by_qty = self.line_ids.filtered(lambda l: l.selected_qty > 0)
+ lines_validation = self.line_ids.filtered(lambda l: l.selected_qty > l.reserved_qty)
lines_by_selected = self.line_ids.filtered(lambda l: l.selected and not l.selected_qty)
selected_lines = lines_by_qty | lines_by_selected # gabung dua domain hasil filter
+ if lines_validation:
+ raise UserError(_("Jumlah yang dipilih melebihi jumlah yang terdapat di DO."))
+
if not selected_lines:
raise UserError(_("Tidak ada produk yang dipilih atau diisi jumlahnya."))
@@ -172,9 +176,11 @@ class PartialDeliveryWizard(models.TransientModel):
for line in selected_lines:
if line.selected_qty > line.reserved_qty:
raise UserError(_("Jumlah produk %s yang dipilih melebihi jumlah reserved.") % line.product_id.display_name)
+
move = line.move_id
move._do_unreserve()
+ # 🔹 Kalau cuma selected tanpa qty → anggap kirim semua reserved qty
if line.selected and not line.selected_qty:
line.selected_qty = line.reserved_qty
@@ -186,12 +192,20 @@ class PartialDeliveryWizard(models.TransientModel):
if line.selected_qty < move.product_uom_qty:
qty_to_keep = move.product_uom_qty - line.selected_qty
+
new_move = move.copy(default={
'product_uom_qty': line.selected_qty,
'picking_id': new_picking.id,
'partial': True,
})
+
+ if move.move_dest_ids:
+ for dest_move in move.move_dest_ids:
+ # dest_move.write({'move_orig_ids': [(4, new_move.id)]})
+ new_move.write({'move_dest_ids': [(4, dest_move.id)]})
+
move.write({'product_uom_qty': qty_to_keep})
+
else:
move.write({'picking_id': new_picking.id, 'partial': True})