From 0d43c8987d05543c20b1ea26e6645afcf153691b Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Wed, 9 Jul 2025 13:04:08 +0700 Subject: (andri) test --- indoteknik_custom/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/account_move.py') diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index df79b9f6..059e8330 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -81,7 +81,7 @@ class AccountMove(models.Model): target_dates_str = [d.isoformat() for d in target_dates] # Ganti nama partner untuk test jika perlu - partner = self.env['res.partner'].search([('name', 'ilike', 'PRIMA SEJAHTERA MARITIM')], limit=1) + partner = self.env['res.partner'].search([('name', 'ilike', 'ROYALTAMA MULIA KONTRAKTORINDO')], limit=1) if not partner: _logger.info("Partner tidak ditemukan.") return -- cgit v1.2.3 From 5e905a9af7f6bb928c44cad2d47f8c6e69662bd2 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Wed, 9 Jul 2025 13:08:41 +0700 Subject: (andri) test --- indoteknik_custom/models/account_move.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indoteknik_custom/models/account_move.py') diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 059e8330..8ef3d273 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -81,7 +81,7 @@ class AccountMove(models.Model): target_dates_str = [d.isoformat() for d in target_dates] # Ganti nama partner untuk test jika perlu - partner = self.env['res.partner'].search([('name', 'ilike', 'ROYALTAMA MULIA KONTRAKTORINDO')], limit=1) + partner = self.env['res.partner'].search([('name', 'ilike', 'DAYA ANUGRAH MULYA')], limit=1) if not partner: _logger.info("Partner tidak ditemukan.") return -- cgit v1.2.3 From c72db0d0fa214e6691fa9a293020e7091a9c82c2 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Wed, 9 Jul 2025 13:42:33 +0700 Subject: (andri) fix invoices --- indoteknik_custom/models/account_move.py | 36 +++++++++++++++++++------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'indoteknik_custom/models/account_move.py') diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 8ef3d273..e63f4cb2 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -76,12 +76,9 @@ class AccountMove(models.Model): def send_due_invoice_reminder(self): today = fields.Date.today() - reminder_days = [-7, -3, 0, 3, 7] - target_dates = [today + timedelta(days=delta) for delta in reminder_days] - target_dates_str = [d.isoformat() for d in target_dates] # Ganti nama partner untuk test jika perlu - partner = self.env['res.partner'].search([('name', 'ilike', 'DAYA ANUGRAH MULYA')], limit=1) + partner = self.env['res.partner'].search([('name', 'ilike', 'TIRTA FRESINDO JAYA')], limit=1) if not partner: _logger.info("Partner tidak ditemukan.") return @@ -92,6 +89,7 @@ class AccountMove(models.Model): ('payment_state', 'not in', ['paid','in_payment', 'reversed']), ('invoice_date_due', '>=', today - timedelta(days=7)), ('invoice_date_due', '>=', today - timedelta(days=3)), + ('invoice_date_due', '>=', today - timedelta(days=0)), ('invoice_date_due', '<=', today + timedelta(days=3)), ('invoice_date_due', '<=', today + timedelta(days=7)), ('partner_id', '=', partner.id), @@ -115,17 +113,25 @@ class AccountMove(models.Model): # Ambil template template = self.env.ref('indoteknik_custom.mail_template_invoice_due_reminder') - for inv in invoices: - try: - # Untuk test: override ke email pribadi Anda - email_values = { - 'email_to': 'andrifebriyadiputra@gmail.com', - 'email_from': 'finance@indoteknik.co.id', - } - template.send_mail(inv.id, force_send=True, email_values=email_values) - _logger.info(f"Reminder terkirim: {inv.name} → {email_values['email_to']}") - except Exception as e: - _logger.error(f"Gagal kirim email untuk {inv.name}: {str(e)}") + try: + template.with_context(invoices=invoices).send_mail(partner.id, force_send=True, email_values={ + 'email_to': 'andrifebriyadiputra@gmail.com', # test override + }) + _logger.info(f"Reminder terkirim ke {partner.name} → {len(invoices)} invoice") + except Exception as e: + _logger.error(f"Gagal kirim email ke {partner.name}: {str(e)}") + + # for inv in invoices: + # try: + # # Untuk test: override ke email pribadi Anda + # email_values = { + # 'email_to': 'andrifebriyadiputra@gmail.com', + # 'email_from': 'finance@indoteknik.co.id', + # } + # template.send_mail(inv.id, force_send=True, email_values=email_values) + # _logger.info(f"Reminder terkirim: {inv.name} → {email_values['email_to']}") + # except Exception as e: + # _logger.error(f"Gagal kirim email untuk {inv.name}: {str(e)}") # def name_get(self): # result = [] -- cgit v1.2.3 From 028480352e86ac8cbfef5ea4834caf111ebfb3d4 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Wed, 9 Jul 2025 14:04:27 +0700 Subject: (andri) try --- indoteknik_custom/models/account_move.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'indoteknik_custom/models/account_move.py') diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index e63f4cb2..436dfcaa 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -114,12 +114,15 @@ class AccountMove(models.Model): template = self.env.ref('indoteknik_custom.mail_template_invoice_due_reminder') try: - template.with_context(invoices=invoices).send_mail(partner.id, force_send=True, email_values={ - 'email_to': 'andrifebriyadiputra@gmail.com', # test override - }) - _logger.info(f"Reminder terkirim ke {partner.name} → {len(invoices)} invoice") + email_values = template.with_context(invoices=invoices).generate_email(partner.id) + email_values['email_to'] = 'andrifebriyadiputra@gmail.com' # override untuk test + email_values['email_from'] = 'finance@indoteknik.co.id' + + self.env['mail.mail'].create(email_values).send() + _logger.info(f"[Reminder Terkirim] ke {partner.name} → {len(invoices)} invoice") except Exception as e: - _logger.error(f"Gagal kirim email ke {partner.name}: {str(e)}") + _logger.error(f"[Reminder Gagal] ke {partner.name} → {str(e)}") + # for inv in invoices: # try: -- cgit v1.2.3 From 00b357fa35ff809c153a5aeaf67f97a00715e463 Mon Sep 17 00:00:00 2001 From: "Indoteknik ." Date: Wed, 9 Jul 2025 14:33:52 +0700 Subject: (andr) try2 --- indoteknik_custom/models/account_move.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indoteknik_custom/models/account_move.py') diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 436dfcaa..c3908daf 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -114,7 +114,9 @@ class AccountMove(models.Model): template = self.env.ref('indoteknik_custom.mail_template_invoice_due_reminder') try: - email_values = template.with_context(invoices=invoices).generate_email(partner.id) + email_values = template.with_context(invoices=invoices).generate_email( + partner.id, + ['subject', 'body_html', 'email_to', 'email_from']) email_values['email_to'] = 'andrifebriyadiputra@gmail.com' # override untuk test email_values['email_from'] = 'finance@indoteknik.co.id' -- cgit v1.2.3