summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models
diff options
context:
space:
mode:
authorIndoteknik . <it@fixcomart.co.id>2025-07-18 14:30:09 +0700
committerIndoteknik . <it@fixcomart.co.id>2025-07-18 14:30:09 +0700
commit51a363741a7c40d91052e90f7d1aa0f6defc2f99 (patch)
tree01c9305a4dc3210cfbda31c9688b4ac85a9f19ec /indoteknik_custom/models
parentb839d55d39856031b6abfeb8f304b77b0fb145ce (diff)
(andri) add due date
Diffstat (limited to 'indoteknik_custom/models')
-rw-r--r--indoteknik_custom/models/down_payment.py29
1 files changed, 27 insertions, 2 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