diff options
| author | Indoteknik . <it@fixcomart.co.id> | 2025-07-18 14:30:09 +0700 |
|---|---|---|
| committer | Indoteknik . <it@fixcomart.co.id> | 2025-07-18 14:30:09 +0700 |
| commit | 51a363741a7c40d91052e90f7d1aa0f6defc2f99 (patch) | |
| tree | 01c9305a4dc3210cfbda31c9688b4ac85a9f19ec | |
| parent | b839d55d39856031b6abfeb8f304b77b0fb145ce (diff) | |
(andri) add due date
| -rw-r--r-- | indoteknik_custom/models/down_payment.py | 29 | ||||
| -rw-r--r-- | indoteknik_custom/views/down_payment.xml | 4 | ||||
| -rw-r--r-- | indoteknik_custom/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 @@ <field name="departement_type"/> <field name="status_pay_down_payment" readonly="1"/> <field name="create_date" readonly="1"/> + <field name="estimated_return_date" readonly="1"/> + <field name="days_remaining" readonly="1"/> <field name="detail_note" attrs="{'readonly': [('status', '=', 'approved')]}"/> </group> </group> @@ -80,6 +82,8 @@ decoration-success="status_pay_down_payment == 'payment'" decoration-danger="status_pay_down_payment == 'pending'" widget="badge"/> + <field name="estimated_return_date" optional="hide"/> + <field name="days_remaining" readonly="1"/> </tree> </field> </record> 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 @@ <field name="model">realization.down.payment</field> <field name="arch" type="xml"> <form string="Realisasi Uang Muka"> + <header> + <button name="action_validation" + type="object" + string="Validasi" + class="btn-primary" + attrs="{}"/> + </header> <sheet> <h1> <field name="title" class="oe_title"/> </h1> - <group col="2"> <group> <field name="pum_id" readonly="1"/> |
