summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiqdad <ahmadmiqdad27@gmail.com>2025-06-26 21:33:44 +0700
committerMiqdad <ahmadmiqdad27@gmail.com>2025-06-26 21:33:44 +0700
commit2c3358216c4a2b09ef0df3a2f8998889198ad310 (patch)
treeeca17f59e95758b07c16c3b9acf5d3b44fa6bbb9
parentbc99ea265c50e22d0a6cd74e1e5a4d5f27988701 (diff)
<miqdad> add validations
-rw-r--r--indoteknik_custom/models/stock_picking_return.py9
-rw-r--r--indoteknik_custom/models/tukar_guling.py22
2 files changed, 30 insertions, 1 deletions
diff --git a/indoteknik_custom/models/stock_picking_return.py b/indoteknik_custom/models/stock_picking_return.py
index 74bf6407..982f3ebb 100644
--- a/indoteknik_custom/models/stock_picking_return.py
+++ b/indoteknik_custom/models/stock_picking_return.py
@@ -12,6 +12,10 @@ class StockReturnPicking(models.TransientModel):
], string='Jenis Retur', default='revisi_so')
def create_returns(self):
+ picking = self.picking_id
+ if picking.picking_type_id.sequence_code == 'PICK' or picking.picking_type_id.id == 30 and picking.linked_manual_bu_out.state == 'done':
+ raise UserError("❌ BU/PICK tidak dapat di retur karena BU/OUT Sudah Done")
+
if self._context.get('from_ui', True) and self.return_type == 'tukar_guling':
return self._redirect_to_tukar_guling()
return super(StockReturnPicking, self).create_returns()
@@ -21,6 +25,9 @@ class StockReturnPicking(models.TransientModel):
self.ensure_one()
picking = self.picking_id
+ if picking.picking_type_id.sequence_code == 'PICK' or picking.picking_type_id.id == 30 and picking.linked_manual_bu_out.state == 'done':
+ raise UserError("❌ BU/PICK tidak dapat di retur karena BU/OUT Sudah Done")
+
# Get valid return lines with better error handling
valid_lines = []
@@ -145,4 +152,4 @@ class ReturnPickingLine(models.TransientModel):
raise UserError(
_("Quantity yang Anda masukkan (%.2f) tidak boleh melebihi quantity done yaitu: %.2f untuk produk %s")
% (rec.quantity, qty_done, rec.product_id.name)
- ) \ No newline at end of file
+ )
diff --git a/indoteknik_custom/models/tukar_guling.py b/indoteknik_custom/models/tukar_guling.py
index 601603d7..e1513c2e 100644
--- a/indoteknik_custom/models/tukar_guling.py
+++ b/indoteknik_custom/models/tukar_guling.py
@@ -243,8 +243,30 @@ class TukarGuling(models.Model):
def action_submit(self):
self.ensure_one()
+ picking = self.operations
+
if self.state != 'draft':
raise UserError("Submit hanya bisa dilakukan dari Draft.")
+
+ if not self.operations:
+ raise UserError("Operations harus diisi!")
+
+ if not self.return_type:
+ raise UserError("Return Type harus diisi!")
+
+ self._validate_product_lines()
+
+ if picking.picking_type_id.sequence_code == 'OUT' or picking.picking_type_id.id == 29:
+ if picking.state != 'done':
+ raise UserError("BU/OUT Harus Sudah DONE")
+
+ elif picking.picking_type_id.sequence_code == 'PICK' or picking.picking_type_id.id == 30:
+ linked_bu_out = picking.linked_manual_bu_out
+ if linked_bu_out.state == 'done':
+ raise UserError("BU/PICK yang bisa diretur ketika BU/OUT yang belum DONE")
+ else:
+ raise UserError("Picking Type harus BU/OUT atau BU/PICK")
+
self.state = 'approval_sales'
def action_approve(self):