summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indoteknik_custom/models/stock_picking.py2
-rw-r--r--indoteknik_custom/models/tukar_guling.py20
2 files changed, 13 insertions, 9 deletions
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 7c4cea8b..f69e5fa9 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -1603,7 +1603,7 @@ class StockPicking(models.Model):
self.tukar_guling_po_id.update_doc_state()
user = self.env.user
- if not user.has_group('indoteknik_custom.group_role_logistic'):
+ if not user.has_group('indoteknik_custom.group_role_logistic') and 'BU/IU' in self.name:
raise UserWarning('Validate hnaya bisa di lakukan oleh logistik')
return res
diff --git a/indoteknik_custom/models/tukar_guling.py b/indoteknik_custom/models/tukar_guling.py
index 99a74505..aa116ce3 100644
--- a/indoteknik_custom/models/tukar_guling.py
+++ b/indoteknik_custom/models/tukar_guling.py
@@ -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: