diff options
| author | Indoteknik . <it@fixcomart.co.id> | 2025-07-19 13:47:28 +0700 |
|---|---|---|
| committer | Indoteknik . <it@fixcomart.co.id> | 2025-07-19 13:47:28 +0700 |
| commit | 09c24278d60eb5bc5a92ad9b3f5389d329641228 (patch) | |
| tree | 858fd6873600e985f1eafd2aca1e9d322d45b0ac | |
| parent | f9cd84314e7a725fbe5001aa39201f632562bfc6 (diff) | |
(andri) add attachment & validasi realisasi penggunaan PUM
| -rw-r--r-- | indoteknik_custom/models/down_payment.py | 51 | ||||
| -rw-r--r-- | indoteknik_custom/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 @@ <button name="action_validation" type="object" string="Validasi" - class="btn-primary" - attrs="{}"/> + class="btn-primary"/> <field name="done_status" widget="statusbar" statusbar_visible="remaining,done_not_realized,done_realized" statusbar_colors='{"done_realized":"green"}' readonly="1"/> </header> + <sheet> - <h1> - <field name="name" class="oe_title"/> - </h1> + <h1><field name="name" class="oe_title"/></h1> + <group col="2"> <group> <field name="pum_id" readonly="1"/> @@ -44,12 +43,32 @@ <page string="Rincian Penggunaan"> <field name="penggunaan_line_ids" nolabel="1"> - <tree editable="bottom"> + <tree> <field name="date"/> <field name="description"/> <field name="nominal" sum="Total Penggunaan"/> - <field name="attachment"/> + <field name="done_attachment"/> </tree> + + <form> + <group> + <field name="date"/> + <field name="description"/> + <field name="nominal"/> + <field name="attachment_type"/> + + <field name="attachment_file_pdf" + filename="attachment_filename_pdf" + widget="pdf_viewer" + attrs="{'invisible': [('attachment_type', '!=', 'pdf')]}"/> + + <field name="attachment_file_image" + filename="attachment_filename_image" + widget="image" + attrs="{'invisible': [('attachment_type', '!=', 'image')]}"/> + <field name="done_attachment"/> + </group> + </form> </field> </page> </notebook> @@ -64,9 +83,10 @@ </group> </group> </sheet> + <div class="oe_chatter"> - <field name="message_follower_ids" widget="mail_followers"/> - <field name="message_ids" widget="mail_thread"/> + <field name="message_follower_ids" widget="mail_followers"/> + <field name="message_ids" widget="mail_thread"/> </div> </form> </field> |
