From 02511349a98e9488ed91795a062774f7d3ad26a6 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Sat, 7 Jun 2025 13:41:09 +0700 Subject: (andri) Nomor CAB serta nominal terisi otomatis ketika create reklas --- indoteknik_custom/models/invoice_reklas.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/indoteknik_custom/models/invoice_reklas.py b/indoteknik_custom/models/invoice_reklas.py index d10d4c31..8641ca07 100644 --- a/indoteknik_custom/models/invoice_reklas.py +++ b/indoteknik_custom/models/invoice_reklas.py @@ -18,6 +18,17 @@ class InvoiceReklas(models.TransientModel): ('pembelian', 'Pembelian'), ], string='Reklas Tipe') + @api.model + def default_get(self, fields): + res = super().default_get(fields) + active_ids = self._context.get('active_ids', []) + if active_ids: + move = self.env['account.move'].browse(active_ids[0]) + if move.move_type == 'entry': + res['reklas_id'] = move.id + res['pay_amt'] = move.amount_total # atau amount_residual jika mau sisa + return res + @api.onchange('reklas_type') def _onchange_reklas_type(self): if self.reklas_type == 'penjualan': -- cgit v1.2.3