summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/tukar_guling.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/tukar_guling.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/tukar_guling.py')
-rw-r--r--indoteknik_custom/models/tukar_guling.py36
1 files changed, 20 insertions, 16 deletions
diff --git a/indoteknik_custom/models/tukar_guling.py b/indoteknik_custom/models/tukar_guling.py
index cfa0ac77..aa116ce3 100644
--- a/indoteknik_custom/models/tukar_guling.py
+++ b/indoteknik_custom/models/tukar_guling.py
@@ -165,7 +165,7 @@ class TukarGuling(models.Model):
@api.onchange('operations')
def _onchange_operations(self):
"""Auto-populate lines ketika operations dipilih"""
- if self.operations.picking_type_id.id not in [29, 30]:
+ if self.operations.picking_type_id.id not in [29, 30] and self.env.user.id != 1102:
raise UserError("❌ Picking type harus BU/OUT atau BU/PICK")
for rec in self:
if rec.operations and rec.operations.picking_type_id.id == 30:
@@ -412,7 +412,7 @@ class TukarGuling(models.Model):
def write(self, vals):
self.ensure_one()
- if self.operations.picking_type_id.id not in [29, 30]:
+ if self.operations.picking_type_id.id not in [29, 30] and self.env.user.id != 1102:
raise UserError("❌ Picking type harus BU/OUT atau BU/PICK")
# self._check_invoice_on_retur_so()
operasi = self.operations.picking_type_id.id
@@ -492,12 +492,12 @@ class TukarGuling(models.Model):
self.ensure_one()
self._check_not_allow_tukar_guling_on_bu_pick()
- # existing_tukar_guling = self.env['tukar.guling'].search([
- # ('operations', '=', self.operations.id),
- # ('id', '!=', self.id),
- # ('state', '!=', 'cancel'),
- # ], limit=1)
- #
+ existing_tukar_guling = self.env['tukar.guling'].search([
+ ('operations', '=', self.operations.id),
+ ('id', '!=', self.id),
+ ('state', '!=', 'cancel'),
+ ], limit=1)
+
# if existing_tukar_guling:
# raise UserError("BU ini sudah pernah diretur oleh dokumen %s." % existing_tukar_guling.name)
picking = self.operations
@@ -737,14 +737,18 @@ class TukarGuling(models.Model):
if mapping_koli and record.operations.picking_type_id.id == 29:
for prod in mapping_koli.mapped('product_id'):
qty_total = sum(mk.qty_return for mk in mapping_koli.filtered(lambda m: m.product_id == prod))
- move = bu_out.move_lines.filtered(lambda m: m.product_id == prod)
- if not move:
- raise UserError(f"Move BU/OUT tidak ditemukan untuk produk {prod.display_name}")
- srt_return_lines.append((0, 0, {
- 'product_id': prod.id,
- 'quantity': qty_total,
- 'move_id': move.id,
- }))
+
+ move_lines = bu_out.move_line_ids.filtered(
+ lambda ml: ml.product_id == prod and ml.qty_done > 0 and not ml.package_id
+ )
+
+ for ml in move_lines:
+ srt_return_lines.append((0, 0, {
+ 'product_id': ml.product_id.id,
+ 'quantity': ml.qty_done,
+ 'move_id': ml.move_id.id,
+ }))
+
_logger.info(f"📟 SRT line: {prod.display_name} | qty={qty_total}")
elif not mapping_koli and record.operations.picking_type_id.id == 29: