From 0fe7320b3b32fa41fd06e30040171c6bf9800897 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Tue, 26 Aug 2025 09:57:51 +0700 Subject: (andri) add grand total inv --- indoteknik_custom/models/account_move.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 599b3220..6f3190f0 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -247,8 +247,10 @@ class AccountMove(models.Model): _logger.info(f"Email tujuan: {email_to}") invoice_table_rows = "" + grand_total = 0 for inv in invs: days_to_due = (inv.invoice_date_due - today).days if inv.invoice_date_due else 0 + grand_total += inv.amount_total invoice_table_rows += f""" {inv.partner_id.name} @@ -261,6 +263,15 @@ class AccountMove(models.Model): {days_to_due} """ + invoice_table_footer = f""" + + + Grand Total + {formatLang(self.env, grand_total, currency_obj=invs[0].currency_id)} + + + + """ days_to_due_message = "" closing_message = "" @@ -302,7 +313,7 @@ class AccountMove(models.Model): body_html = re.sub( r"]*>.*?", - f"{invoice_table_rows}", + f"{invoice_table_rows}{invoice_table_footer}", template.body_html, flags=re.DOTALL ).replace('${object.name}', partner.name) \ @@ -323,16 +334,16 @@ class AccountMove(models.Model): # Siapkan email values values = { 'subject': f"Reminder Invoice Due - {partner.name}", - # 'email_to': 'andrifebriyadiputra@gmail.com', - 'email_to': email_to, + 'email_to': 'andrifebriyadiputra@gmail.com', + # 'email_to': email_to, 'email_from': 'finance@indoteknik.co.id', - 'email_cc': ",".join(sorted(set(cc_list))), + # 'email_cc': ",".join(sorted(set(cc_list))), 'body_html': body_html, - 'reply_to': 'finance@indoteknik.co.id', + # 'reply_to': 'finance@indoteknik.co.id', } - # template.send_mail(invs[0].id, force_send=True, email_values=values) - _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) + # _logger.info(f"Mengirim email ke: {values['email_to']} > email CC: {values['email_cc']}") _logger.info(f"Reminder terkirim ke {partner.name} ({values['email_to']}) → {len(invs)} invoice (dtd = {dtd})") # flag invs.write({'reminder_sent_date': today}) -- cgit v1.2.3