From 51a363741a7c40d91052e90f7d1aa0f6defc2f99 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Fri, 18 Jul 2025 14:30:09 +0700 Subject: (andri) add due date --- indoteknik_custom/models/down_payment.py | 29 ++++++++++++++++++++-- indoteknik_custom/views/down_payment.xml | 4 +++ .../views/down_payment_realization.xml | 8 +++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/indoteknik_custom/models/down_payment.py b/indoteknik_custom/models/down_payment.py index 14f0b171..e9fd51d0 100644 --- a/indoteknik_custom/models/down_payment.py +++ b/indoteknik_custom/models/down_payment.py @@ -1,6 +1,6 @@ from odoo import models, api, fields, _ from odoo.exceptions import UserError -from datetime import datetime +from datetime import date, datetime, timedelta # import datetime import logging _logger = logging.getLogger(__name__) @@ -27,6 +27,15 @@ class DownPayment(models.Model): bank_account = fields.Char(string='No. Rekening', tracking=3, required=True) detail_note = fields.Text(string='Keterangan Penggunaan Rinci', tracking=3) + estimated_return_date = fields.Date( + string='Estimasi Batas Durasi Pengajuan' + ) + + days_remaining = fields.Integer( + string='Due Date', + compute='_compute_days_remaining', + ) + status = fields.Selection([ ('draft', 'Draft'), ('pengajuan1', 'Menunggu Approval Departement'), @@ -117,12 +126,25 @@ class DownPayment(models.Model): def action_draft(self): for record in self: record.status = record.last_status if record.last_status else 'draft' - return + return + + @api.depends('create_date') + def _compute_days_remaining(self): + today = date.today() + for rec in self: + if rec.create_date: + due_date = rec.create_date.date() + timedelta(days=7) + rec.days_remaining = (due_date - today).days + else: + rec.days_remaining = 0 @api.model def create(self, vals): if not vals.get('number') or vals['number'] == 'New Draft': vals['number'] = self.env['ir.sequence'].next_by_code('down.payment') or 'New Draft' + + if not vals.get('estimated_return_date'): + vals['estimated_return_date'] = date.today() + timedelta(days=7) return super(DownPayment, self).create(vals) @@ -191,6 +213,9 @@ class RealizationDownPayment(models.Model): for rec in self: rec.remaining_value = rec.value_down_payment - rec.grand_total_use + def action_validation(self): + # Logic untuk konfirmasi pembayaran + return diff --git a/indoteknik_custom/views/down_payment.xml b/indoteknik_custom/views/down_payment.xml index 3830154f..4c327d36 100644 --- a/indoteknik_custom/views/down_payment.xml +++ b/indoteknik_custom/views/down_payment.xml @@ -50,6 +50,8 @@ + + @@ -80,6 +82,8 @@ decoration-success="status_pay_down_payment == 'payment'" decoration-danger="status_pay_down_payment == 'pending'" widget="badge"/> + + diff --git a/indoteknik_custom/views/down_payment_realization.xml b/indoteknik_custom/views/down_payment_realization.xml index ab8034c6..3dcd2a8e 100644 --- a/indoteknik_custom/views/down_payment_realization.xml +++ b/indoteknik_custom/views/down_payment_realization.xml @@ -4,11 +4,17 @@ realization.down.payment
+
+

- -- cgit v1.2.3