diff options
| author | Indoteknik . <it@fixcomart.co.id> | 2025-07-10 15:16:28 +0700 |
|---|---|---|
| committer | Indoteknik . <it@fixcomart.co.id> | 2025-07-10 15:16:28 +0700 |
| commit | 659a62598fd984a233e9eee6f40ee6408ce17ac6 (patch) | |
| tree | 005df74098fae11463fbadd699b5610b0348a453 /indoteknik_custom/models/dunning_run.py | |
| parent | 6aee89eff0e1511c257c60fac9fa84172729063c (diff) | |
| parent | 0a66ca2c69581100f5a0800152a6d80a07351d6c (diff) | |
(andri) fix conflict
Diffstat (limited to 'indoteknik_custom/models/dunning_run.py')
| -rw-r--r-- | indoteknik_custom/models/dunning_run.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py index bb53fc0c..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([{ @@ -123,8 +132,9 @@ class DunningRunLine(models.Model): _name = 'dunning.run.line' _description = 'Dunning Run Line' # _order = 'dunning_id, id' - _order = 'invoice_id desc, id' + _order = 'invoice_number asc, id' + invoice_number = fields.Char('Invoice Number', related='invoice_id.name') dunning_id = fields.Many2one('dunning.run', string='Dunning Ref', required=True, ondelete='cascade', index=True, copy=False) partner_id = fields.Many2one('res.partner', string='Customer') invoice_id = fields.Many2one('account.move', string='Invoice') |
