summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIndoteknik . <it@fixcomart.co.id>2025-07-23 11:06:12 +0700
committerIndoteknik . <it@fixcomart.co.id>2025-07-23 11:06:12 +0700
commitd02c3d5d0522e6ec5a43d1380c078f0dd5fd1275 (patch)
tree44d12ba59e29d9eea91a119abdbfbadc6447a1ed
parent7e6927b4fd7bcd9981ce56f3fc24f8a1b685be0d (diff)
(andri) add reject & set to draft Pengajuan PUM
-rw-r--r--indoteknik_custom/models/down_payment.py55
-rwxr-xr-xindoteknik_custom/security/ir.model.access.csv3
-rw-r--r--indoteknik_custom/views/down_payment.xml39
3 files changed, 84 insertions, 13 deletions
diff --git a/indoteknik_custom/models/down_payment.py b/indoteknik_custom/models/down_payment.py
index afb8ca73..8f449566 100644
--- a/indoteknik_custom/models/down_payment.py
+++ b/indoteknik_custom/models/down_payment.py
@@ -95,6 +95,8 @@ class DownPayment(models.Model):
move_id = fields.Many2one('account.move', string='Journal Entries', domain=[('move_type', '=', 'entry')])
is_cab_visible = fields.Boolean(string='Is Journal Uang Muka Visible', compute='_compute_is_cab_visible')
+ reason_reject = fields.Text(string='Alasan Penolakan')
+
@api.depends('move_id.state')
def _compute_is_cab_visible(self):
for rec in self:
@@ -268,13 +270,42 @@ class DownPayment(models.Model):
def action_reject(self):
- # Logic untuk konfirmasi pembayaran
- return
+ return {
+ 'type': 'ir.actions.act_window',
+ 'name': 'Alasan Penolakan',
+ 'res_model': 'reject.reason.downpayment',
+ 'view_mode': 'form',
+ 'target': 'new',
+ 'context': {'default_request_id': self.id},
+ }
def action_draft(self):
for record in self:
- record.status = record.last_status if record.last_status else 'draft'
- return
+ # Pastikan hanya yang statusnya 'reject' yang bisa di-reset
+ if record.status != 'reject':
+ raise UserError("Hanya data dengan status 'Reject' yang bisa dikembalikan ke Draft atau status sebelumnya.")
+
+ # Jika ada last_status, gunakan itu; jika tidak, fallback ke 'draft'
+ new_status = record.last_status or 'draft'
+
+ # Reset field-field approval & alasan reject
+ record.write({
+ 'status': new_status,
+ 'reason_reject': False,
+ 'last_status': False,
+ 'name_approval_departement': False,
+ 'name_approval_ap': False,
+ 'name_approval_pimpinan': False,
+ 'date_approved_department': False,
+ 'date_approved_ap': False,
+ 'date_approved_pimpinan': False,
+ 'position_department': False,
+ 'position_ap': False,
+ 'position_pimpinan': False,
+ })
+
+ record.message_post(body=f"Status dikembalikan ke <b>{new_status.capitalize()}</b> oleh {self.env.user.name}.")
+
def action_ap_only(self):
# if self.env.user.id != 23:
@@ -657,7 +688,21 @@ class RealizationDownPayment(models.Model):
# rec.message_post(body=f"Approval oleh {self.env.user.name} pada tahap <b>{rec.status}</b>.")
-
+class RejectReasonDownPayment(models.TransientModel):
+ _name = 'reject.reason.downpayment'
+ _description = 'Wizard for Reject Reason Down Payment'
+
+ request_id = fields.Many2one('down.payment', string='Pengajuan PUM')
+ reason_reject = fields.Text(string='Alasan Penolakan', required=True)
+
+ def confirm_reject(self):
+ if self.request_id:
+ self.request_id.write({
+ 'status': 'reject',
+ 'last_status': self.request_id.status,
+ 'reason_reject': self.reason_reject,
+ })
+ return {'type': 'ir.actions.act_window_close'}
class DownPaymentApOnly(models.TransientModel):
_name = 'down.payment.ap.only'
diff --git a/indoteknik_custom/security/ir.model.access.csv b/indoteknik_custom/security/ir.model.access.csv
index e463caa8..2fd497b9 100755
--- a/indoteknik_custom/security/ir.model.access.csv
+++ b/indoteknik_custom/security/ir.model.access.csv
@@ -187,4 +187,5 @@ access_down_payment,access.down.payment,model_down_payment,,1,1,1,1
access_realization_down_payment,access.realization.down.payment,model_realization_down_payment,,1,1,1,1
access_realization_down_payment_line,access.realization.down.payment.line,model_realization_down_payment_line,,1,1,1,1
access_realization_down_payment_use_line,access.realization.down.payment.use.line,model_realization_down_payment_use_line,,1,1,1,1
-access_down_payment_ap_only,access.down.payment.ap.only,model_down_payment_ap_only,,1,1,1,1 \ No newline at end of file
+access_down_payment_ap_only,access.down.payment.ap.only,model_down_payment_ap_only,,1,1,1,1
+access_reject_reason_downpayment,access.reject.reason.downpayment,model_reject_reason_downpayment,,1,1,1,1 \ No newline at end of file
diff --git a/indoteknik_custom/views/down_payment.xml b/indoteknik_custom/views/down_payment.xml
index 47e3c2be..467697a4 100644
--- a/indoteknik_custom/views/down_payment.xml
+++ b/indoteknik_custom/views/down_payment.xml
@@ -10,7 +10,7 @@
type="object"
string="Realisasi"
class="btn-primary"
- attrs="{}"/>
+ attrs="{'invisible': [('status', '=', 'reject')]}"/>
<button name="action_draft"
string="Reset to Draft"
attrs="{'invisible': [('status', '!=', 'reject')]}"
@@ -18,19 +18,20 @@
<button name="action_reject"
type="object"
string="Reject"
+ class="btn-danger"
attrs="{'invisible': [('status', 'in', ['approved','reject'])]}"/>
<button name="action_confirm_payment"
type="object"
string="Konfirmasi Pembayaran"
- attrs="{}"/>
+ attrs="{'invisible': [('status', '=', 'reject')]}"/>
<button name="action_approval_check"
type="object"
string="Checking/Approval"
- attrs="{}"/>
+ attrs="{'invisible': [('status', '=', 'reject')]}"/>
<button name="action_ap_only"
type="object"
string="AP Only"
- attrs="{}"/>
+ attrs="{'invisible': [('status', '=', 'reject')]}"/>
<field name="status" widget="statusbar"
statusbar_visible="draft,pengajuan1,pengajuan2,pengajuan3,approved"
statusbar_colors='{"reject":"red"}'
@@ -80,15 +81,15 @@
</group>
<group>
- <field name="attachment_type"/>
+ <field name="attachment_type" attrs="{'readonly': [('status', '=', 'approved')]}"/>
<field name="attachment_file_pdf" filename="attachment_filename"
widget="pdf_viewer"
- attrs="{'invisible': [('attachment_type', '!=', 'pdf')]}"/>
+ attrs="{'invisible': [('attachment_type', '!=', 'pdf')], 'readonly': [('status', '=', 'approved')]}"/>
<field name="attachment_file_image" filename="attachment_filename"
widget="image"
- attrs="{'invisible': [('attachment_type', '!=', 'image')]}"
+ attrs="{'invisible': [('attachment_type', '!=', 'image')], 'readonly': [('status', '=', 'approved')]}"
style="max-width:250px; max-height:250px; object-fit:contain;"/>
<br/>
</group>
@@ -173,4 +174,28 @@
<field name="target">new</field>
</record>
+
+ <record id="view_reject_reason_downpayment_form" model="ir.ui.view">
+ <field name="name">reject.reason.downpayment.form</field>
+ <field name="model">reject.reason.downpayment</field>
+ <field name="arch" type="xml">
+ <form string="Alasan Penolakan PUM">
+ <group>
+ <field name="reason_reject"/>
+ </group>
+ <footer>
+ <button name="confirm_reject" type="object" string="Tolak" class="btn-danger"/>
+ <button string="Batal" class="btn-secondary" special="cancel"/>
+ </footer>
+ </form>
+ </field>
+ </record>
+
+ <record id="action_down_payment_reject" model="ir.actions.act_window">
+ <field name="name">Tolak Pengajuan PUM</field>
+ <field name="res_model">reject.reason.downpayment</field>
+ <field name="view_mode">form</field>
+ <field name="target">new</field>
+ </record>
+
</odoo> \ No newline at end of file