diff options
| author | Indoteknik . <it@fixcomart.co.id> | 2025-08-26 09:57:51 +0700 |
|---|---|---|
| committer | Indoteknik . <it@fixcomart.co.id> | 2025-08-26 09:57:51 +0700 |
| commit | 0fe7320b3b32fa41fd06e30040171c6bf9800897 (patch) | |
| tree | 40cc8c7fa859c6c30b463790b9b5ecde89496d73 | |
| parent | a5fcc1fe80508de9c827d6f5c5d06db3262a8ab0 (diff) | |
(andri) add grand total inv
| -rw-r--r-- | indoteknik_custom/models/account_move.py | 25 |
1 files 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""" <tr> <td>{inv.partner_id.name}</td> @@ -261,6 +263,15 @@ class AccountMove(models.Model): <td>{days_to_due}</td> </tr> """ + invoice_table_footer = f""" + <tfoot> + <tr style="font-weight:bold; background-color:#f9f9f9;"> + <td colspan="5" align="right">Grand Total</td> + <td>{formatLang(self.env, grand_total, currency_obj=invs[0].currency_id)}</td> + <td colspan="2"></td> + </tr> + </tfoot> + """ days_to_due_message = "" closing_message = "" @@ -302,7 +313,7 @@ class AccountMove(models.Model): body_html = re.sub( r"<tbody[^>]*>.*?</tbody>", - f"<tbody>{invoice_table_rows}</tbody>", + f"<tbody>{invoice_table_rows}</tbody>{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}) |
