summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-08-06 14:49:35 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-08-06 14:49:35 +0700
commit3ea10365d477bba3e5565dc636824a2b42bc8fca (patch)
tree2632edb60b864a189695b73f24a7f51a545845d7
parentcad9851dc642c877dcb1913e5bb12dc6405d9652 (diff)
refactor due extension
-rw-r--r--indoteknik_custom/models/account_move_due_extension.py9
-rw-r--r--indoteknik_custom/views/account_move_views.xml6
2 files changed, 14 insertions, 1 deletions
diff --git a/indoteknik_custom/models/account_move_due_extension.py b/indoteknik_custom/models/account_move_due_extension.py
index 4a3f40e2..d354e3e3 100644
--- a/indoteknik_custom/models/account_move_due_extension.py
+++ b/indoteknik_custom/models/account_move_due_extension.py
@@ -33,6 +33,7 @@ class DueExtension(models.Model):
counter = fields.Integer(string="Counter", compute='_compute_counter')
approve_by = fields.Many2one('res.users', string="Approve By", readonly=True)
date_approve = fields.Datetime(string="Date Approve", readonly=True)
+
def _compute_counter(self):
for due in self:
due.counter = due.partner_id.counter
@@ -102,6 +103,14 @@ class DueExtension(models.Model):
self.date_approve = datetime.utcnow()
template = self.env.ref('indoteknik_custom.mail_template_due_extension_approve')
template.send_mail(self.id, force_send=True)
+ return {
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'sale.order',
+ 'view_mode': 'form',
+ 'res_id': self.order_id.id,
+ 'views': [(False, 'form')],
+ 'target': 'current',
+ }
def generate_due_line(self):
partners = self.partner_id.get_child_ids()
diff --git a/indoteknik_custom/views/account_move_views.xml b/indoteknik_custom/views/account_move_views.xml
index da25636e..0fd7c9cd 100644
--- a/indoteknik_custom/views/account_move_views.xml
+++ b/indoteknik_custom/views/account_move_views.xml
@@ -47,15 +47,20 @@
<button name="approve_new_due"
string="Approve"
type="object"
+ attrs="{'readonly': [('approval_status', 'in', ('approved'))]}"
/>
<button name="due_extension_approval"
string="Ask Approval"
type="object"
+ attrs="{'readonly': [('approval_status', 'in', ('approved'))]}"
/>
<button name="due_extension_cancel"
string="Cancel"
type="object"
+ attrs="{'readonly': [('approval_status', 'in', ('approved'))]}"
/>
+ <field name="approval_status" widget="statusbar"
+ statusbar_visible="pengajuan,approved"/>
</header>
<sheet>
<group>
@@ -67,7 +72,6 @@
<group>
<field name="is_approve" readonly="1"/>
<field name="counter" readonly="1"/>
- <field name="approval_status" readonly="1"/>
<field name="approve_by" readonly="1"/>
<field name="date_approve" readonly="1"/>
</group>