From 17c147f8c988c36c46e035e954c0d90f3ea18f20 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Sat, 19 Jul 2025 08:51:19 +0700 Subject: (andri) fix realization --- indoteknik_custom/models/down_payment.py | 46 +++++++++++++++++----- indoteknik_custom/views/down_payment.xml | 20 ++++++++-- .../views/down_payment_realization.xml | 5 ++- 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/indoteknik_custom/models/down_payment.py b/indoteknik_custom/models/down_payment.py index e9fd51d0..68f6954d 100644 --- a/indoteknik_custom/models/down_payment.py +++ b/indoteknik_custom/models/down_payment.py @@ -69,6 +69,9 @@ class DownPayment(models.Model): ('hr_ga', 'HR & GA'), ], string='Departement Type', tracking=3, required=True) + attachment_file = fields.Binary(string="Attachment") + + # Sales & MD : Darren ID 19 # Marketing : Iwan ID 216 # Logistic & Procurement : Rafly H ID 21 @@ -90,17 +93,39 @@ class DownPayment(models.Model): return mapping.get(self.departement_type) def action_realisasi_pum(self): - return { - 'type': 'ir.actions.act_window', - 'name': 'Realisasi PUM', - 'res_model': 'realization.down.payment', - 'view_mode': 'form', - 'target': 'current', - 'context': { - 'default_pum_id': self.id, - 'default_value_down_payment': self.nominal, + self.ensure_one() + + realization = self.env['realization.down.payment'].search([('pum_id', '=', self.id)], limit=1) + + if realization: + return { + 'type': 'ir.actions.act_window', + 'name': 'Realisasi PUM', + 'res_model': 'realization.down.payment', + 'view_mode': 'form', + 'target': 'current', + 'res_id': realization.id, + } + else: + return { + 'type': 'ir.actions.act_window', + 'name': 'Realisasi PUM', + 'res_model': 'realization.down.payment', + 'view_mode': 'form', + 'target': 'current', + 'context': { + 'default_pum_id': self.id, + 'default_value_down_payment': self.nominal, + 'default_name': f'Realisasi - {self.number or ""}', + 'default_pemberian_line_ids': [ + (0, 0, { + 'date': self.create_date.date() if self.create_date else fields.Date.today(), + 'description': 'Uang Muka', + 'value': self.nominal + }) + ] + } } - } def action_confirm_payment(self): @@ -175,6 +200,7 @@ class RealizationDownPayment(models.Model): _inherit = ['mail.thread'] pum_id = fields.Many2one('down.payment', string='No PUM') + name = fields.Char(string='Nama', readonly=True, tracking=3) title = fields.Char(string='Judul', tracking=3) goals = fields.Text(string='Tujuan', tracking=3) related = fields.Char(string='Terkait', tracking=3,) diff --git a/indoteknik_custom/views/down_payment.xml b/indoteknik_custom/views/down_payment.xml index 4c327d36..55edad4e 100644 --- a/indoteknik_custom/views/down_payment.xml +++ b/indoteknik_custom/views/down_payment.xml @@ -43,16 +43,30 @@ + + + + + + + + + + + + + + - + @@ -73,6 +87,7 @@ + - diff --git a/indoteknik_custom/views/down_payment_realization.xml b/indoteknik_custom/views/down_payment_realization.xml index 3dcd2a8e..cd9459a9 100644 --- a/indoteknik_custom/views/down_payment_realization.xml +++ b/indoteknik_custom/views/down_payment_realization.xml @@ -13,11 +13,12 @@

- +

+ @@ -29,7 +30,7 @@ - + -- cgit v1.2.3