diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2025-07-10 08:03:14 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2025-07-10 08:03:14 +0000 |
| commit | 0a66ca2c69581100f5a0800152a6d80a07351d6c (patch) | |
| tree | 2f417cbd9e3c7299e1f8dd49c6bcc31c2d79a190 | |
| parent | f8f97d82904db540f7ae8b21ada28ac06a718c55 (diff) | |
| parent | 710c5100c5ba4f0a02210418e96a14b66ca03698 (diff) | |
Merged in sort_dunning_run (pull request #352)
<miqdad> sort dunning run based on invoice num
| -rw-r--r-- | indoteknik_custom/models/dunning_run.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index d7178cb4..341b206d 100644 --- a/indoteknik_custom/models/dunning_run.py +++ b/indoteknik_custom/models/dunning_run.py @@ -92,10 +92,19 @@ class DunningRun(models.Model): ('move_type', '=', 'out_invoice'), ('state', '=', 'posted'), ('partner_id', '=', partner.id), - # ('amount_residual_signed', '>', 0), ('date_kirim_tukar_faktur', '=', False), ] - invoices = self.env['account.move'].search(query, order='invoice_date') + invoices = self.env['account.move'].search(query) + + # sort by last number in invoice name + try: + invoices = sorted( + invoices, + key=lambda x: int((x.name or '0').split('/')[-1]) + ) + except Exception as e: + _logger.error('Gagal sort invoice number: %s', e) + count = 0 for invoice in invoices: self.env['dunning.run.line'].create([{ |
