diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-07-14 20:25:52 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-07-14 20:25:52 +0700 |
| commit | 15198bbee7d54580fadec9be6cbf69fb4a2d500d (patch) | |
| tree | ff2731b7d68bfe6b2dcc62c0462e59d048809cf5 | |
| parent | 2f90a316e0895b7b3167ee1ff36d282736456a2d (diff) | |
<miqdad> vals PO
| -rw-r--r-- | indoteknik_custom/models/tukar_guling_po.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/indoteknik_custom/models/tukar_guling_po.py b/indoteknik_custom/models/tukar_guling_po.py index 3698f95a..ba2b3800 100644 --- a/indoteknik_custom/models/tukar_guling_po.py +++ b/indoteknik_custom/models/tukar_guling_po.py @@ -6,6 +6,7 @@ import logging _logger = logging.getLogger(__name__) + class TukarGulingPO(models.Model): _name = 'tukar.guling.po' _description = 'Tukar Guling PO' @@ -27,7 +28,7 @@ class TukarGulingPO(models.Model): domain=[ ('picking_type_id.id', 'in', [75, 28]), ('state', '=', 'done') - ],help='Nomor BU INPUT atau BU PUT' + ], help='Nomor BU INPUT atau BU PUT' ) ba_num = fields.Char('Nomor BA') return_type = fields.Selection([ @@ -143,6 +144,15 @@ class TukarGulingPO(models.Model): self.origin = False + def _check_not_allow_tukar_guling_on_bu_input(self, return_type=None): + operasi = self.operations.picking_type_id.id + tipe = return_type or self.return_type + + if operasi == 28 and self.operations.linked_manual_bu_out.state == 'done': + raise UserError("❌ Tidak bisa retur BU/INPUT karena BU/PUT sudah done") + if operasi == 28 and tipe == 'tukar_guling': + raise UserError("❌ BU/INPUT tidak boleh di retur tukar guling") + def action_populate_lines(self): """Manual button untuk populate lines - sebagai alternatif""" self.ensure_one() @@ -270,7 +280,7 @@ class TukarGulingPO(models.Model): def unlink(self): for record in self: if record.state == 'done': - raise UserError ("Tidak bisa hapus pengajuan jika sudah done, set ke draft terlebih dahulu") + raise UserError("Tidak bisa hapus pengajuan jika sudah done, set ke draft terlebih dahulu") ongoing_bu = self.po_picking_ids.filtered(lambda p: p.state != 'done') for picking in ongoing_bu: picking.action_cancel() @@ -299,6 +309,7 @@ class TukarGulingPO(models.Model): self.ensure_one() self._check_bill_on_revisi_po() self._validate_product_lines() + self._check_not_allow_tukar_guling_on_bu_input() if self.operations and self.operations.picking_type_id.id == 28 and self.return_type == 'tukar_guling': group = self.operations.group_id @@ -332,6 +343,7 @@ class TukarGulingPO(models.Model): self.ensure_one() self._validate_product_lines() self._check_bill_on_revisi_po() + self._check_not_allow_tukar_guling_on_bu_input() if not self.operations: raise UserError("Operations harus diisi!") @@ -511,7 +523,6 @@ class TukarGulingPO(models.Model): raise UserError("Tidak ada dokumen retur yang berhasil dibuat.") - class TukarGulingLinePO(models.Model): _name = 'tukar.guling.line.po' _description = 'Tukar Guling PO Line' @@ -526,4 +537,4 @@ class TukarGulingLinePO(models.Model): class StockPicking(models.Model): _inherit = 'stock.picking' - tukar_guling_po_id = fields.Many2one('tukar.guling.po', string='Tukar Guling PO Ref')
\ No newline at end of file + tukar_guling_po_id = fields.Many2one('tukar.guling.po', string='Tukar Guling PO Ref') |
