From f46a71310cc775be744e583ee67a2a1ced8edff1 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 5 Jul 2024 11:15:13 +0700 Subject: activate function send email document efaktur --- indoteknik_custom/models/account_move.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index fbadd2aa..a7010bbe 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -78,18 +78,20 @@ class AccountMove(models.Model): }) return attachment - # @api.constrains('efaktur_document') + @api.constrains('efaktur_document') def send_scheduled_email(self): # Get the records for which emails need to be sent 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, force_send=True) + if record.invoice_payment_term_id.id == 26: + attachment = self.generate_attachment(record) + email_values = { + 'attachment_ids': [(4, attachment.id)] + } + template.send_mail(record.id, email_values=email_values, force_send=True) @api.model def create(self, vals): -- cgit v1.2.3