summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-10-14 14:12:23 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-10-14 14:12:23 +0700
commitb41c2d160e5e114bf805baed573d791fbac3feac (patch)
tree92251733b4775a565b85693f62d37e078751d507
parent724d7ed6d85ecc3acadbcf56a98aead0512af01d (diff)
push
-rw-r--r--indoteknik_custom/models/partial_delivery.py37
1 files changed, 19 insertions, 18 deletions
diff --git a/indoteknik_custom/models/partial_delivery.py b/indoteknik_custom/models/partial_delivery.py
index 977cceed..4df7da1e 100644
--- a/indoteknik_custom/models/partial_delivery.py
+++ b/indoteknik_custom/models/partial_delivery.py
@@ -116,22 +116,31 @@ class PartialDeliveryWizard(models.TransientModel):
lines_by_qty = self.line_ids.filtered(lambda l: l.selected_qty > 0)
lines_by_selected = self.line_ids.filtered(lambda l: l.selected and not l.selected_qty)
- selected_lines = lines_by_qty | lines_by_selected
+ selected_lines = lines_by_qty | lines_by_selected # gabung dua domain hasil filter
if not selected_lines:
raise UserError(_("Tidak ada produk yang dipilih atau diisi jumlahnya."))
- all_selected = len(selected_lines) == len(self.line_ids)
- full_selected = all_selected and all(
- (line.selected_qty or line.reserved_qty) >= line.reserved_qty
- for line in selected_lines
+ # 🧠 Cek apakah semua move di DO sudah muncul di wizard dan semua dipilih
+ picking_move_ids = picking.move_ids_without_package.ids
+ wizard_move_ids = self.line_ids.mapped('move_id').ids
+
+ # Semua move DO muncul di wizard, dan semua baris dipilih
+ full_selected = (
+ set(picking_move_ids) == set(wizard_move_ids)
+ and len(selected_lines) == len(self.line_ids)
+ and all(
+ (line.selected_qty or line.reserved_qty) >= line.reserved_qty
+ for line in selected_lines
+ )
)
if full_selected:
+ # 💡 Gak perlu bikin picking baru, langsung ubah state_reserve
picking.write({'state_reserve': 'partial'})
picking.message_post(
- body=f"<b>Full Picking Confirmed</b> dari wizard partial delivery oleh {self.env.user.name}",
+ body=f"<b>Full Picking Confirmed</b> via wizard partial delivery oleh {self.env.user.name} (tanpa DO baru)",
message_type="comment",
subtype_xmlid="mail.mt_note",
)
@@ -144,11 +153,12 @@ class PartialDeliveryWizard(models.TransientModel):
"target": "current",
"effect": {
"fadeout": "slow",
- "message": f"✅ Semua produk dikirim penuh — tidak dibuat DO baru.",
+ "message": f"✅ Semua produk dari DO ini dikirim penuh — tidak dibuat DO baru.",
"type": "rainbow_man",
},
}
+ # 🧩 Kalau bukan full selected, lanjut bikin DO baru
new_picking = StockPicking.create({
'origin': picking.origin,
'partner_id': picking.partner_id.id,
@@ -187,7 +197,6 @@ class PartialDeliveryWizard(models.TransientModel):
new_picking.action_confirm()
new_picking.action_assign()
-
picking.action_assign()
existing_partials = self.env['stock.picking'].search([
@@ -196,14 +205,8 @@ class PartialDeliveryWizard(models.TransientModel):
('id', '!=', new_picking.id),
], order='name asc')
- suffix_number = len(existing_partials)
- if suffix_number == 0:
- suffix_number = 1
- else:
- suffix_number += 1
-
- new_name = f"{picking.name}/{suffix_number}"
- new_picking.name = new_name
+ suffix_number = len(existing_partials) + 1
+ new_picking.name = f"{picking.name}/{suffix_number}"
if picking.origin:
sale_order = self.env['sale.order'].search([('name', '=', picking.origin)], limit=1)
@@ -234,8 +237,6 @@ class PartialDeliveryWizard(models.TransientModel):
},
}
-
-
class PartialDeliveryWizardLine(models.TransientModel):
_name = 'partial.delivery.wizard.line'
_description = 'Partial Delivery Wizard Line'