From f9cd84314e7a725fbe5001aa39201f632562bfc6 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Sat, 19 Jul 2025 11:15:15 +0700 Subject: (andri) add attachment & add status done validation at realization --- indoteknik_custom/models/down_payment.py | 41 +++++++++++++++++++--- indoteknik_custom/views/down_payment.xml | 21 +++++------ .../views/down_payment_realization.xml | 4 +++ 3 files changed, 50 insertions(+), 16 deletions(-) diff --git a/indoteknik_custom/models/down_payment.py b/indoteknik_custom/models/down_payment.py index 68f6954d..ad359408 100644 --- a/indoteknik_custom/models/down_payment.py +++ b/indoteknik_custom/models/down_payment.py @@ -69,8 +69,22 @@ class DownPayment(models.Model): ('hr_ga', 'HR & GA'), ], string='Departement Type', tracking=3, required=True) - attachment_file = fields.Binary(string="Attachment") - + attachment_file_image = fields.Binary(string='Attachment Image', attachment_filename='attachment_filename_image') + attachment_file_pdf = fields.Binary(string='Attachment PDF', attachment_filename='attachment_filename_pdf') + attachment_filename_image = fields.Char(string='Filename Image') + attachment_filename_pdf = fields.Char(string='Filename PDF') + + attachment_type = fields.Selection([ + ('pdf', 'PDF'), + ('image', 'Image'), + ], string="Attachment Type", default='pdf') + + @api.onchange('attachment_type') + def _onchange_attachment_type(self): + self.attachment_file_image = False + self.attachment_filename_image = False + self.attachment_file_pdf = False + self.attachment_filename_pdf = False # Sales & MD : Darren ID 19 # Marketing : Iwan ID 216 @@ -219,6 +233,12 @@ class RealizationDownPayment(models.Model): note_approval = fields.Text(string='Note Persetujuan', tracking=3) + done_status = fields.Selection([ + ('remaining', 'Remaining'), + ('done_not_realized', 'Done Not Realized'), + ('done_realized', 'Done Realized') + ], string='Status Realisasi', tracking=3, default='remaining') + currency_id = fields.Many2one( 'res.currency', string='Currency', default=lambda self: self.env.company.currency_id @@ -240,8 +260,21 @@ class RealizationDownPayment(models.Model): rec.remaining_value = rec.value_down_payment - rec.grand_total_use def action_validation(self): - # Logic untuk konfirmasi pembayaran - return + self.ensure_one() + + # Validasi hanya AP yang bisa validasi + if self.env.user.id != 23: + raise UserError('Hanya AP yang dapat melakukan validasi realisasi.') + + if self.done_status == 'remaining': + self.done_status = 'done_not_realized' + elif self.done_status == 'done_not_realized': + self.done_status = 'done_realized' + else: + raise UserError('Realisasi sudah berstatus Done Realized.') + + # Opsional: Tambah log di chatter + self.message_post(body=f"Status realisasi diperbarui menjadi {dict(self._fields['done_status'].selection).get(self.done_status)} oleh {self.env.user.name}.") diff --git a/indoteknik_custom/views/down_payment.xml b/indoteknik_custom/views/down_payment.xml index 55edad4e..322b18f6 100644 --- a/indoteknik_custom/views/down_payment.xml +++ b/indoteknik_custom/views/down_payment.xml @@ -43,6 +43,7 @@ +
@@ -53,21 +54,17 @@ - - - + + - - - + +
diff --git a/indoteknik_custom/views/down_payment_realization.xml b/indoteknik_custom/views/down_payment_realization.xml index cd9459a9..74acaed1 100644 --- a/indoteknik_custom/views/down_payment_realization.xml +++ b/indoteknik_custom/views/down_payment_realization.xml @@ -10,6 +10,10 @@ string="Validasi" class="btn-primary" attrs="{}"/> +

-- cgit v1.2.3