Skip to content

Commit

Permalink
allow sending mails right after creation
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcCalvoC committed Oct 21, 2024
1 parent 4766a3d commit 3d76248
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion poweremail_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,15 +1125,27 @@ def generate_mail_sync(self, cursor, user, template_id, record_ids, context=None
# Generating email, attachments and event
if not template.save_to_drafts:
pe_obj = self.pool.get('poweremail.mailbox')
send_on_creation = self.check_send_email_on_creation(cursor, user, context=context)
if self.check_outbox(cursor, user, mailbox_id, context=context):
pe_obj.write(cursor, user, mailbox_id, {'folder': 'outbox'}, context=context)
if send_on_creation:
self.send_this_mail(cursor, user, [mailbox_id], context=context)
else:
pe_obj.write(cursor, user, mailbox_id, {'folder': 'outbox'}, context=context)
if len(mailbox_ids) > 1:
return mailbox_ids
elif mailbox_ids:
return mailbox_ids[0]
else:
return False

def check_send_email_on_creation(self, cursor, uid, context=None):
if context is None:
context = {}
conf_o = self.pool.get('res.config')

send_on_creation = int(conf_o.get(cursor, uid, 'send_signature_email_on_creation', '0'))
return send_on_creation

def create_action_reference(self, cursor, uid, ids, context):
template = self.pool.get('poweremail.templates').browse(
cursor, uid, ids[0]
Expand Down

0 comments on commit 3d76248

Please sign in to comment.