From e33f2d321ee4db6a6e6a86e35243100b9f107f22 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Thu, 27 Jun 2024 15:29:16 +0700 Subject: logbook bill & send email efaktur document --- indoteknik_custom/models/account_move.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 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 d81726e9..2996623c 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -66,7 +66,6 @@ class AccountMove(models.Model): @api.model def generate_attachment(self, record): # Fetch the binary field - # TODO nathan tolong rapihin file_content = record.efaktur_document file_name = "efaktur_document_{}.pdf".format(record.id) # Adjust the file extension if necessary @@ -79,21 +78,18 @@ class AccountMove(models.Model): }) return attachment - @api.model + @api.constrains('efaktur_document') def send_scheduled_email(self): # Get the records for which emails need to be sent - # records = self.search([]) # Adjust the domain as necessary - # TODO nathan tolong rapihin - records = self.env['account.move'].search([('id', '=', 194697)]) - # template = self.env.ref('my_module.email_template_example') - template = self.env['mail.template'].search([('id', '=', 8)]) + records = self.search([('id', 'in', self.ids)]) + template = self.env.ref('indoteknik_custom.mail_template_efaktur_document') for record in records: attachment = self.generate_attachment(record) email_values = { 'attachment_ids': [(4, attachment.id)] } - template.send_mail(record.id, email_values=email_values) + template.send_mail(record.id, email_values=email_values, force_send=True) @api.model def create(self, vals): -- cgit v1.2.3