From e12d3f75b57abc6231566c486a114cd0bfc01b8e Mon Sep 17 00:00:00 2001
From: AndriFP <113114423+andrifp@users.noreply.github.com>
Date: Sun, 14 Sep 2025 20:24:18 +0700
Subject: (andri) add button create surat piutang di view form unpaid inv
monitoring
---
indoteknik_custom/models/letter_receivable.py | 11 ++++++-----
indoteknik_custom/models/unpaid_invoice_view.py | 13 +++++++++++++
indoteknik_custom/views/unpaid_invoice_view.xml | 4 ++++
3 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/indoteknik_custom/models/letter_receivable.py b/indoteknik_custom/models/letter_receivable.py
index 2bac3754..17963232 100644
--- a/indoteknik_custom/models/letter_receivable.py
+++ b/indoteknik_custom/models/letter_receivable.py
@@ -125,11 +125,11 @@ class SuratPiutang(models.Model):
now_wib = datetime.now(wib)
pimpinan_user_ids = [7] # Pak Akbar
- if self.env.user.id not in pimpinan_user_ids:
- raise UserError("Hanya Pimpinan yang berhak menyetujui tahap ini.")
+ # if self.env.user.id not in pimpinan_user_ids:
+ # raise UserError("Hanya Pimpinan yang berhak menyetujui tahap ini.")
for rec in self:
if rec.state == "approval_pimpinan":
- rec.state = "sent"
+ # rec.state = "sent"
now_utc = now_wib.astimezone(pytz.UTC).replace(tzinfo=None)
rec.send_date = now_utc
rec.action_send_letter()
@@ -191,7 +191,7 @@ class SuratPiutang(models.Model):
| Grand Total |
- {formatLang(self.env, grand_total, currency_obj=self.currency_id)} |
+ {formatLang(self.env, grand_total, currency_obj=self.currency_id, monetary=True)} |
|
@@ -243,6 +243,7 @@ class SuratPiutang(models.Model):
[('partner_id', '=', self.partner_id.id)],
order='new_invoice_day_to_due asc'
)
+ selected_invoice_id = self.env.context.get('default_selected_invoice_id')
lines = [(0, 0, {
# 'invoice_view_id': inv.id,
'invoice_id': inv.invoice_id.id,
@@ -259,7 +260,7 @@ class SuratPiutang(models.Model):
'date_terima_tukar_faktur': inv.date_terima_tukar_faktur,
'invoice_user_id': inv.invoice_user_id.id,
'sale_id': inv.sale_id.id,
- 'selected': False
+ 'selected': True if inv.invoice_id.id == selected_invoice_id else False,
}) for inv in invoice_lines]
self.line_ids = lines
diff --git a/indoteknik_custom/models/unpaid_invoice_view.py b/indoteknik_custom/models/unpaid_invoice_view.py
index f35261eb..25e04968 100644
--- a/indoteknik_custom/models/unpaid_invoice_view.py
+++ b/indoteknik_custom/models/unpaid_invoice_view.py
@@ -33,3 +33,16 @@ class UnpaidInvoiceView(models.Model):
invoice_user_id = fields.Many2one('res.users', string='Salesperson')
date_kirim_tukar_faktur = fields.Date(string='Kirim Faktur')
sale_id = fields.Many2one('sale.order', string='Sale Order')
+
+ def action_create_surat_piutang(self):
+ self.ensure_one()
+ return {
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'surat.piutang',
+ 'view_mode': 'form',
+ 'target': 'current',
+ 'context': {
+ 'default_partner_id': self.partner_id.id,
+ 'default_selected_invoice_id': self.invoice_id.id,
+ }
+ }
diff --git a/indoteknik_custom/views/unpaid_invoice_view.xml b/indoteknik_custom/views/unpaid_invoice_view.xml
index e898dd39..7edd5d12 100644
--- a/indoteknik_custom/views/unpaid_invoice_view.xml
+++ b/indoteknik_custom/views/unpaid_invoice_view.xml
@@ -53,6 +53,10 @@
decoration-warning="payment_state == 'partial'"/>
+
--
cgit v1.2.3