diff options
| -rw-r--r-- | indoteknik_custom/models/account_move.py | 14 |
1 files 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): |
