diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2025-05-07 13:42:00 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2025-05-07 13:42:00 +0700 |
| commit | 5d54ea0ad8d3c3a5dc125507122c395ac27a5729 (patch) | |
| tree | a294d3ff022f702f9ba246680c1c96c0b8c37d87 /indoteknik_custom/models/account_move.py | |
| parent | ab1c5cabe7bdcfb950a2d7201ce367eea49ad7f2 (diff) | |
push
Diffstat (limited to 'indoteknik_custom/models/account_move.py')
| -rw-r--r-- | indoteknik_custom/models/account_move.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 906985de..30de67be 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -66,6 +66,19 @@ class AccountMove(models.Model): other_taxes = fields.Float(string="Other Taxes", compute='compute_other_taxes') is_hr = fields.Boolean(string="Is HR?", default=False) purchase_order_id = fields.Many2one('purchase.order', string='Purchase Order') + length_of_payment = fields.Integer(string="Length of Payment", compute='compute_length_of_payment') + + def compute_length_of_payment(self): + for rec in self: + payment_term = rec.invoice_payment_term_id.line_ids[0].days + terima_faktur = rec.date_terima_tukar_faktur + payment = self.search([('ref', '=', rec.name), ('move_type', '=', 'entry')], limit=1) + + if payment and terima_faktur: + date_diff = terima_faktur - payment.date + rec.length_of_payment = date_diff.days + payment_term + else: + rec.length_of_payment = 0 def _update_line_name_from_ref(self): """Update all account.move.line name fields with ref from account.move""" |
