diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-06-26 21:33:44 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-06-26 21:33:44 +0700 |
| commit | 2c3358216c4a2b09ef0df3a2f8998889198ad310 (patch) | |
| tree | eca17f59e95758b07c16c3b9acf5d3b44fa6bbb9 /indoteknik_custom/models/tukar_guling.py | |
| parent | bc99ea265c50e22d0a6cd74e1e5a4d5f27988701 (diff) | |
<miqdad> add validations
Diffstat (limited to 'indoteknik_custom/models/tukar_guling.py')
| -rw-r--r-- | indoteknik_custom/models/tukar_guling.py | 22 |
1 files changed, 22 insertions, 0 deletions
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): |
