summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/dunning_run.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-07-11 15:27:51 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-07-11 15:27:51 +0700
commit887db07ff8a79fdbaeddc07b6b09ff169f428a6c (patch)
tree802b919825785a9fb648408241df58048b0766ac /indoteknik_custom/models/dunning_run.py
parent3021a1d4836a47721500d03eeed80ba029334b98 (diff)
parent575a7a506382487a625914a7bde9a18b20173cc6 (diff)
Merge branch 'odoo-backup' of bitbucket.org:altafixco/indoteknik-addons into odoo-backup
Diffstat (limited to 'indoteknik_custom/models/dunning_run.py')
-rw-r--r--indoteknik_custom/models/dunning_run.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/indoteknik_custom/models/dunning_run.py b/indoteknik_custom/models/dunning_run.py
index bb53fc0c..5a6aebac 100644
--- a/indoteknik_custom/models/dunning_run.py
+++ b/indoteknik_custom/models/dunning_run.py
@@ -92,10 +92,23 @@ 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 full berdasarkan tahun, bulan, nomor
+ def invoice_key(x):
+ try:
+ parts = x.name.split('/')
+ tahun = int(parts[1])
+ bulan = int(parts[2])
+ nomor = int(parts[3])
+ return (tahun, bulan, nomor)
+ except Exception:
+ return (0, 0, 0)
+
+ invoices = sorted(invoices, key=invoice_key)
+
count = 0
for invoice in invoices:
self.env['dunning.run.line'].create([{
@@ -123,8 +136,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')