diff options
| author | Miqdad <ahmadmiqdad27@gmail.com> | 2025-07-24 17:35:11 +0700 |
|---|---|---|
| committer | Miqdad <ahmadmiqdad27@gmail.com> | 2025-07-24 17:35:11 +0700 |
| commit | b8efc85091fe0af596872bffeb3cf6c78fe2beed (patch) | |
| tree | 2ca2037b60e8027ec4e1b374c1c16bb1682979a5 /indoteknik_custom/models/tukar_guling_po.py | |
| parent | 4d87e7317448dd7cc46d01e32ac2c953f02d72b1 (diff) | |
<miqdad> cant delete when done and in approval state
Diffstat (limited to 'indoteknik_custom/models/tukar_guling_po.py')
| -rw-r--r-- | indoteknik_custom/models/tukar_guling_po.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/indoteknik_custom/models/tukar_guling_po.py b/indoteknik_custom/models/tukar_guling_po.py index b3279077..7c9680f8 100644 --- a/indoteknik_custom/models/tukar_guling_po.py +++ b/indoteknik_custom/models/tukar_guling_po.py @@ -90,6 +90,9 @@ class TukarGulingPO(models.Model): @api.onchange('operations') def _onchange_operations(self): """Auto-populate lines ketika operations dipilih""" + if self.operations.picking_type_id.id not in [75, 28]: + raise UserError("❌ Picking type harus BU/INPUT atau BU/PUT") + if self.operations: from_return_picking = self.env.context.get('from_return_picking', False) or \ self.env.context.get('default_line_ids', False) @@ -275,6 +278,8 @@ class TukarGulingPO(models.Model): return new_record def write(self, vals): + if self.operations.picking_type_id.id not in [75, 28]: + raise UserError("❌ Tidak bisa retur bukan BU/INPUT atau BU/PUT!") self._check_bill_on_revisi_po() tipe = vals.get('return_type', self.return_type) @@ -621,6 +626,18 @@ class TukarGulingLinePO(models.Model): product_uom = fields.Many2one('uom.uom', string='Unit of Measure') name = fields.Text('Description') + @api.constrains('product_uom_qty') + def _check_qty_change_allowed(self): + for rec in self: + if rec.tukar_guling_id and rec.tukar_guling_po_id.state not in ['draft', 'cancel']: + raise ValidationError("Tidak bisa mengubah Quantity karena status dokumen bukan Draft atau Cancel.") + + def unlink(self): + for rec in self: + if rec.tukar_guling_po_id and rec.tukar_guling_po_id.state not in ['draft', 'cancel']: + raise UserError("Tidak bisa menghapus data karena status dokumen bukan Draft atau Cancel.") + return super(TukarGulingLinePO, self).unlink() + class StockPicking(models.Model): _inherit = 'stock.picking' |
