From 09c24278d60eb5bc5a92ad9b3f5389d329641228 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Sat, 19 Jul 2025 13:47:28 +0700 Subject: (andri) add attachment & validasi realisasi penggunaan PUM --- indoteknik_custom/models/down_payment.py | 51 +++++++++++++++++++++- .../views/down_payment_realization.xml | 38 ++++++++++++---- 2 files changed, 79 insertions(+), 10 deletions(-) diff --git a/indoteknik_custom/models/down_payment.py b/indoteknik_custom/models/down_payment.py index ad359408..920b1b5b 100644 --- a/indoteknik_custom/models/down_payment.py +++ b/indoteknik_custom/models/down_payment.py @@ -205,8 +205,40 @@ class RealizationDownPaymentUseLine(models.Model): date = fields.Date(string='Tanggal', required=True, default=fields.Date.today) description = fields.Char(string='Description', required=True) nominal = fields.Float(string='Nominal', required=True) - attachment = fields.Boolean(string='Lampiran', default=False) + done_attachment = fields.Boolean(string='Checked', default=False) + attachment_type = fields.Selection([ + ('pdf', 'PDF'), + ('image', 'Image'), + ], string="Attachment Type", default='pdf') + + 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') + + @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 + + @api.onchange('done_attachment') + def _onchange_done_attachment(self): + if self.done_attachment and self.env.user.id != 23: + self.done_attachment = False + return { + 'warning': { + 'title': _('Tidak Diizinkan'), + 'message': _('Hanya user AP yang bisa mencentang Done Attachment.') + } + } + # def write(self, vals): + # if 'done_attachment' in vals and vals['done_attachment']: + # if self.env.user.id != 23: # Manzila (Finance) ID 23 + # raise UserError('Hanya user AP yang dapat mencentang Checked.') + # return super().write(vals) class RealizationDownPayment(models.Model): _name = 'realization.down.payment' @@ -244,6 +276,23 @@ class RealizationDownPayment(models.Model): default=lambda self: self.env.company.currency_id ) + 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 + @api.depends('pemberian_line_ids.value') def _compute_grand_total(self): for rec in self: diff --git a/indoteknik_custom/views/down_payment_realization.xml b/indoteknik_custom/views/down_payment_realization.xml index 74acaed1..2ee1a6d5 100644 --- a/indoteknik_custom/views/down_payment_realization.xml +++ b/indoteknik_custom/views/down_payment_realization.xml @@ -8,17 +8,16 @@