summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIndoteknik . <it@fixcomart.co.id>2025-07-19 11:15:15 +0700
committerIndoteknik . <it@fixcomart.co.id>2025-07-19 11:15:15 +0700
commitf9cd84314e7a725fbe5001aa39201f632562bfc6 (patch)
treee1f8b96bcc42d0c2823e7775454a425904fa2775
parent17c147f8c988c36c46e035e954c0d90f3ea18f20 (diff)
(andri) add attachment & add status done validation at realization
-rw-r--r--indoteknik_custom/models/down_payment.py41
-rw-r--r--indoteknik_custom/views/down_payment.xml21
-rw-r--r--indoteknik_custom/views/down_payment_realization.xml4
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 <b>{dict(self._fields['done_status'].selection).get(self.done_status)}</b> 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 @@
<field name="bank_name" colspan="2" attrs="{'readonly': [('status', '=', 'approved')]}"/>
<field name="account_name" colspan="2" attrs="{'readonly': [('status', '=', 'approved')]}"/>
<field name="bank_account" colspan="2" attrs="{'readonly': [('status', '=', 'approved')]}"/>
+ <hr/>
<field name="user_id" readonly="1"/>
<field name="departement_type"/>
<field name="status_pay_down_payment" readonly="1"/>
@@ -53,21 +54,17 @@
</group>
<group>
-
- <field name="attachment_file"/>
- </group>
+ <field name="attachment_type"/>
+ <field name="attachment_file_pdf" filename="attachment_filename"
+ widget="pdf_viewer"
+ attrs="{'invisible': [('attachment_type', '!=', 'pdf')]}"/>
-
- <group string="" col="2">
- <!-- <field name="user_id" readonly="1"/>
- <field name="departement_type"/>
- <field name="status_pay_down_payment" readonly="1"/>
- <field name="create_date" readonly="1"/>
- <field name="estimated_return_date" readonly="1"/>
- <field name="days_remaining" readonly="1"/>
- <field name="detail_note" attrs="{'readonly': [('status', '=', 'approved')]}"/> -->
+ <field name="attachment_file_image" filename="attachment_filename"
+ widget="image"
+ attrs="{'invisible': [('attachment_type', '!=', 'image')]}"/>
</group>
+
</group>
</sheet>
<div class="oe_chatter">
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="{}"/>
+ <field name="done_status" widget="statusbar"
+ statusbar_visible="remaining,done_not_realized,done_realized"
+ statusbar_colors='{"done_realized":"green"}'
+ readonly="1"/>
</header>
<sheet>
<h1>