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

Add template body text optional inliner #155

Open
wants to merge 8 commits into
base: v5_backport
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion poweremail_send_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import tools
from .poweremail_template import get_value
from .poweremail_core import filter_send_emails, _priority_selection
from premailer import transform


class poweremail_send_wizard(osv.osv_memory):
Expand Down Expand Up @@ -138,7 +139,11 @@ def _get_template_value(self, cr, uid, field, context=None):
if len(context['src_rec_ids']) > 1: # Multiple Mail: Gets original template values for multiple email change
return getattr(template, field)
else: # Simple Mail: Gets computed template values
return self.get_value(cr, uid, template, getattr(template, field), context)
value = self.get_value(cr, uid, template, getattr(template, field), context)
if template.inline and field == 'def_body_text':
value = transform(value)

return value

_columns = {
'state':fields.selection([
Expand Down Expand Up @@ -495,6 +500,9 @@ def save_to_mailbox(self, cr, uid, ids, context=None):
# Options:'multipart/mixed','multipart/alternative','text/plain','text/html'
}
ctx = context.copy()
if template.inline:
vals['pem_body_text'] = transform(vals['pem_body_text'])

mail_id = self.create_mail(cr, uid, screen_vals, src_rec_id, vals, context=ctx)
mail_ids.append(mail_id)
# Ensure report is rendered using template's language. If not found, user's launguage is used.
Expand Down
8 changes: 7 additions & 1 deletion poweremail_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ def _get_model_data_name_search(
relation='ir.attachment',
string='Attachments'),
'attach_record_items': fields.boolean('Attach record items', select=2, help=u"Si es marca aquesta opcio, s'enviaran com a fitxers adjunts del email tots els adjunts del registre utilitzat per renderitzar el email."),
'inline': fields.boolean('Inline HTML', help=u"Si es marca aquesta opcio, l'html passara per un proces d'inline"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idioma del mòdul és l'anglès.

'model_data_name': fields.function(
_get_model_data_name, string='Code',
type='char', size=250, method=True,
Expand All @@ -523,7 +524,8 @@ def _get_model_data_name_search(
_defaults = {
'ref_ir_act_window': False,
'ref_ir_value': False,
'def_priority': lambda *a: '1'
'def_priority': lambda *a: '1',
'inline': lambda *a: False
}
_sql_constraints = [
('name', 'unique (name)', _('The template name must be unique!'))
Expand Down Expand Up @@ -1039,6 +1041,10 @@ def _generate_mailbox_item_from_template(self, cursor, user, template, record_id
'priority': template.def_priority,
'template_id': template.id,
}

if template.inline:
mailbox_values['pem_body_text'] = transform(mailbox_values['pem_body_text'])

#Use signatures if allowed
if template.use_sign:
sign = users_obj.read(cursor, user, user, ['signature'], context=context)['signature']
Expand Down
1 change: 1 addition & 0 deletions poweremail_template_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
<field name="single_email" colspan="4"/>
<field name="use_sign" colspan="4"/>
<field name="save_to_drafts" colspan="4"/>
<field name="inline" colspan="4"/>
</group>
<group>
<separator colspan="4" string="Allowed User Groups" />
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mako
qreu>=0.7.5
html2text
premailer==2.9.6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entenc que una versió superior no és compatible amb python 2.7 no?