summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorAndriFP <113114423+andrifp@users.noreply.github.com>2025-09-12 17:34:14 +0700
committerAndriFP <113114423+andrifp@users.noreply.github.com>2025-09-12 17:34:14 +0700
commitf2b1b0ec605b552c2bf225de46094cd4707197ee (patch)
tree15e7ddbece53ff56d07ccbcc795107a25c44cfb4 /indoteknik_custom/models
parentd04150023a7145468858765209e8d6b3724b0fec (diff)
(andri) add penomoran di tabel dan melengkapi teks surat
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/letter_receivable.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/indoteknik_custom/models/letter_receivable.py b/indoteknik_custom/models/letter_receivable.py
index a414eec3..3823a57a 100644
--- a/indoteknik_custom/models/letter_receivable.py
+++ b/indoteknik_custom/models/letter_receivable.py
@@ -347,3 +347,18 @@ class SuratPiutangLine(models.Model):
date_terima_tukar_faktur = fields.Date(string='Terima Faktur')
invoice_user_id = fields.Many2one('res.users', string='Salesperson')
sale_id = fields.Many2one('sale.order', string='Sale Order')
+
+ sort = fields.Integer(string='No Urut', compute='_compute_sort', store=False)
+
+ @api.depends('surat_id.line_ids.selected')
+ def _compute_sort(self):
+ for line in self:
+ if line.surat_id:
+ # Ambil semua line yang selected
+ selected_lines = line.surat_id.line_ids.filtered(lambda l: l.selected)
+ try:
+ line.sort = selected_lines.ids.index(line.id) + 1
+ except ValueError:
+ line.sort = 0
+ else:
+ line.sort = 0