Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permitir enviar emails justo depués de crearlos en vez de dejarlos en el buzón de salida #172

Open
wants to merge 2 commits into
base: v5_backport
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions migrations/5.0.25.1.0/post-0001_load_field_send_immediately.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
import logging
import pooler

from oopgrade.oopgrade import load_data_records
from tools import config

def up(cursor, installed_version):
if not installed_version:
return
if config.updating_all:
return
logger = logging.getLogger('openerp.migration')

logger.info("Creating pooler")
pool = pooler.get_pool(cursor.dbname)

logger.info("Creating table: giscedata.polissa")
pool.get("poweremail.templates")._auto_init(cursor, context={'module': 'poweremail'})
logger.info("Table created succesfully.")

load_data_records(cursor, 'poweremail', 'poweremail_template_view.xml', ['poweremail_template_form'])


def down(cursor, installed_version):
pass


migrate = up
8 changes: 7 additions & 1 deletion poweremail_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,8 @@ def _get_model_data_name_search(
help="Model Data Name.",
fnct_search=_get_model_data_name_search,
),
'send_immediately': fields.boolean('Send Immediately', help="Emails created from this template will be sent"
" immediately without going throug outbox folder.")
}

_defaults = {
Expand Down Expand Up @@ -1125,8 +1127,12 @@ 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_immediately = template.send_immediately
if self.check_outbox(cursor, user, mailbox_id, context=context):
pe_obj.write(cursor, user, mailbox_id, {'folder': 'outbox'}, context=context)
if send_immediately:
pe_obj.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:
Expand Down
1 change: 1 addition & 0 deletions poweremail_template_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
attrs="{'required':[('auto_email','=',True)],'readonly':[('auto_email','=', False)]}" colspan="4"/>
<field name="send_on_create" colspan="4"/>
<field name="send_on_write" colspan="4"/>
<field name="send_immediately" colspan="4"/>
<field name="use_filter" colspan="4"/>
<group string="Filter" colspan="4" attrs="{'invisible':[('use_filter','=',False)]}">
<group colspan="3" col="1">
Expand Down