diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-06-27 15:29:16 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-06-27 15:29:16 +0700 |
| commit | e33f2d321ee4db6a6e6a86e35243100b9f107f22 (patch) | |
| tree | 54da1eeaced0bf1894be9fa4fa00a5f16c76388c /indoteknik_custom/models/account_move.py | |
| parent | 98fd3104060a92991569a206aabf6c7c20b190e3 (diff) | |
logbook bill & send email efaktur document
Diffstat (limited to 'indoteknik_custom/models/account_move.py')
| -rw-r--r-- | indoteknik_custom/models/account_move.py | 12 |
1 files changed, 4 insertions, 8 deletions
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): |
