summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIndoteknik . <it@fixcomart.co.id>2025-08-20 09:58:00 +0700
committerIndoteknik . <it@fixcomart.co.id>2025-08-20 09:58:00 +0700
commitdde108ba7e3690b0ef655fe7449814e9021bab74 (patch)
treef7863e3397104374e13a43305f9a42557b7e34c4
parentc225119cb9bdcee03ca9706ec58dfceb717b5027 (diff)
(andri) add field janji bayar & button sync ke inv customer dengan due date yang sama
-rw-r--r--indoteknik_custom/models/account_move.py48
-rw-r--r--indoteknik_custom/views/account_move.xml7
2 files changed, 54 insertions, 1 deletions
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index b0ffd8b9..3a07cf87 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -99,6 +99,12 @@ class AccountMove(models.Model):
reminder_sent_date = fields.Date(string="Tanggal Reminder Terkirim")
+ customer_promise_date = fields.Date(
+ string="Janji Bayar",
+ help="Tanggal janji bayar dari customer setelah reminder dikirim.",
+ tracking=True
+ )
+
def compute_partial_payment(self):
for move in self:
if move.amount_total_signed > 0 and move.amount_residual_signed > 0 and move.payment_state == 'partial':
@@ -121,6 +127,46 @@ class AccountMove(models.Model):
else:
move.payment_date = False
+ def action_sync_promise_date(self):
+ for inv in self:
+ if not inv.customer_promise_date:
+ inv.env.user.notify_warning(
+ message="Isi Janji Bayar terlebih dahulu sebelum melakukan sinkronisasi.",
+ title="Sync Gagal",
+ )
+ continue
+
+ # Cari invoice lain milik partner yang due date sama
+ other_invoices = self.search([
+ ('id', '!=', inv.id),
+ ('partner_id', '=', inv.partner_id.id),
+ ('invoice_date_due', '=', inv.invoice_date_due),
+ ('move_type', '=', 'out_invoice'),
+ ('state', '=', 'posted'),
+ ])
+
+ if not other_invoices:
+ inv.env.user.notify_info(
+ message="Tidak ada invoice lain dengan due date yang sama untuk disinkronkan.",
+ title="Sync Janji Bayar",
+ )
+ continue
+
+ # Sync field
+ other_invoices.write({'customer_promise_date': inv.customer_promise_date})
+
+ # Log di invoices lain
+ for other in other_invoices:
+ other.message_post(
+ body=f"Janji Bayar {inv.customer_promise_date} disinkronkan dari invoice {inv.name}."
+ )
+
+ # Log di invoice asal
+ other_names = ", ".join(other_invoices.mapped("name"))
+ inv.message_post(
+ body=f"Janji Bayar {inv.customer_promise_date} disinkronkan ke {len(other_invoices)} invoice lain: {other_names}."
+ )
+
def send_due_invoice_reminder(self):
today = fields.Date.today()
@@ -279,7 +325,7 @@ class AccountMove(models.Model):
}
_logger.info(f"Mengirim email ke: {values['email_to']} > email CC: {values['email_cc']}")
- template.send_mail(invs[0].id, force_send=True, email_values=values)
+ # template.send_mail(invs[0].id, force_send=True, email_values=values)
# flag
invs.write({'reminder_sent_date': today})
# Post ke chatter
diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml
index e5d1cf8a..284043d0 100644
--- a/indoteknik_custom/views/account_move.xml
+++ b/indoteknik_custom/views/account_move.xml
@@ -68,6 +68,13 @@
<field name="nomor_kwitansi"/>
<field name="down_payment"/>
</field>
+ <field name="website_id" position="after">
+ <field name="customer_promise_date"/>
+ <button name="action_sync_promise_date"
+ string="Sync Janji Bayar ke Invoice Lain"
+ type="object"
+ class="btn-primary"/>
+ </field>
<field name="to_check" position="after">
<field name="already_paid"/>
<field name="so_shipping_paid_by"/>