[IMP] email_template: another round of review+improvements:

- better search/form views
- improved labels
- consistency in processing of message-id/campaign-item tracking
- auto-select a resource to render in template preview if none was pre-selected
- ...

bzr revid: odo@openerp.com-20100913004342-4jqk1x8uys3ejgm8
This commit is contained in:
Olivier Dony 2010-09-13 02:43:42 +02:00
parent 33cb2c8c9a
commit 05c2556601
5 changed files with 59 additions and 40 deletions

View File

@ -186,10 +186,9 @@ This is useful for CRM leads for example"),
help="the signature from the User details"
" will be appended to the mail"),
'file_name':fields.char(
'File Name Pattern',
'Report Filename',
size=200,
help="File name pattern can be specified with placeholders."
"eg. 2009_SO003.pdf",
help="Name of the generated report file. Placeholders can be used in the filename. eg: 2009_SO003.pdf",
translate=True),
'report_template':fields.many2one(
'ir.actions.report.xml',
@ -646,8 +645,8 @@ This is useful for CRM leads for example"),
# use provided message_id with placeholders
mailbox_values.update({'message_id': get_value(cursor, user, record_id, template['message_id'], template, context)})
if template['track_campaign_item']:
# get appropriate message-id
elif template['track_campaign_item']:
# get appropriate message-id
mailbox_values.update({'message_id': tools.misc.generate_tracking_message_id(record_id)})
if not mailbox_values['account_id']:
@ -734,7 +733,7 @@ class email_template_preview(osv.osv_memory):
context = {}
#Fills up the selection box which allows records from the selected object to be displayed
self.context = context
if 'template_id' in context.keys():
if 'template_id' in context:
ref_obj_id = self.pool.get('email.template').read(cr, uid, context['template_id'], ['object_name'], context)
ref_obj_name = self.pool.get('ir.model').read(cr, uid, ref_obj_id['object_name'][0], ['model'], context)['model']
model_obj = self.pool.get(ref_obj_name)
@ -746,6 +745,16 @@ class email_template_preview(osv.osv_memory):
ref_obj_ids.insert(0, default_id)
return model_obj.name_get(cr, uid, ref_obj_ids, context)
def default_get(self, cr, uid, fields, context=None):
if context is None:
context = {}
result = super(email_template_preview, self).default_get(cr, uid, fields, context=context)
if (not fields or 'rel_model_ref' in fields) and 'template_id' in context \
and not result.get('rel_model_ref'):
selectables = self._get_model_recs(cr, uid, context=context)
result['rel_model_ref'] = selectables and selectables[0][0] or False
return result
def _default_model(self, cursor, user, context=None):
"""
Returns the default value for model field
@ -786,7 +795,7 @@ class email_template_preview(osv.osv_memory):
}
_defaults = {
'ref_template': lambda self, cr, uid, ctx:ctx['template_id'],
'rel_model': _default_model
'rel_model': _default_model,
}
def on_change_ref(self, cr, uid, ids, rel_model_ref, context=None):
if context is None:

View File

@ -92,15 +92,15 @@ unless it is already specified in the From Email, e.g: John Doe <john@doe.com>",
'email_id': fields.char('From Email',
size=120, required=True,
readonly=True, states={'draft':[('readonly', False)]} ,
help="eg: yourname@yourdomain.com "),
help="eg: 'john@doe.com' or 'John Doe <john@doe.com>'"),
'smtpserver': fields.char('Server',
size=120, required=True,
readonly=True, states={'draft':[('readonly', False)]},
help="Enter name of outgoing server, eg:smtp.gmail.com "),
'smtpport': fields.integer('SMTP Port ',
help="Enter name of outgoing server, eg: smtp.yourdomain.com"),
'smtpport': fields.integer('SMTP Port',
size=64, required=True,
readonly=True, states={'draft':[('readonly', False)]},
help="Enter port number,eg:SMTP-587 "),
help="Enter port number, eg: 25 or 587"),
'smtpuname': fields.char('User Name',
size=120, required=False,
readonly=True, states={'draft':[('readonly', False)]},

View File

@ -20,12 +20,12 @@
<separator string="Server Information" colspan="4" />
<group colspan="4" col="4">
<field name="smtpserver" select="1"/>
<button name="check_outgoing_connection" type="object" string="Test Outgoing Connection" icon="gtk-network" colspan="2"/>
<field name="smtpport" select="2" />
<field name="smtpssl" select="2" />
<field name="smtptls" select="2" />
<field name="auto_delete" />
</group>
<button name="check_outgoing_connection" type="object" string="Test Outgoing Connection" icon="gtk-network"/>
<separator string="User Information" colspan="4" />
<group col="2" colspan="2">
<field name="email_id" select="1" colspan="2" />
@ -55,14 +55,15 @@
<field name="model">email_template.account</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree colors="blue:state in ('draft');black:state in ('suspended','approved')" string="SMTP Server">
<field name="name" select="2" />
<field name="email_id" select="2" />
<field name="smtpuname" select="2" />
<field name="user" select="2" />
<field name="smtpserver" select="2" />
<field name="smtpport" select="2" />
<field name="state" select="2" />
<tree colors="blue:state in ('draft');black:state in ('suspended','approved')" string="Email Accounts">
<field name="name" />
<field name="email_id" />
<field name="smtpuname" />
<field name="user" />
<field name="smtpserver" />
<field name="smtpport" />
<field name="auto_delete" />
<field name="state" />
</tree>
</field>
</record>
@ -72,7 +73,7 @@
<field name="model">email_template.account</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Accounts">
<search string="Email Accounts">
<filter icon="terp-document-new" string="Draft" name="draft" domain="[('state','=','draft')]"/>
<filter icon="terp-camera_test" string="Approved" domain="[('state','=','approved')]"/>
<filter icon="terp-emblem-important" string="Suspended" domain="[('state','=','suspended')]"/>

View File

@ -89,7 +89,7 @@
<field name="email_from"/>
<field name="user">
<filter icon="terp-personal"
string="My Emails" name="myemails"
string="My Emails" help="My Emails" name="myemails"
domain="[('account_id.user','=', uid)]" />
</field>
<newline/>

View File

@ -133,9 +133,9 @@
<field name="attachment_ids" colspan="4" nolabel="1" height="350"/>
</page>
<page string="Report">
<field name="file_name" colspan="4" />
<field name="report_template" colspan="4"
domain="[('model','=',model_int_name)]" />
<field name="file_name" colspan="4" />
</page>
</notebook>
</group>
@ -151,15 +151,17 @@
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Email Templates">
<field name="name" select="1" />
<field name="object_name" required="1" select="1" />
<field name="def_to" colspan="4" select="2" />
<field name="def_cc" colspan="4" select="2" />
<field name="def_bcc" colspan="4" select="2" />
<field name="def_subject" colspan="4" select="2" />
<field name="use_sign" colspan="4" select="2" />
<field name="file_name" colspan="4" />
<field name="from_account" />
<field name="name"/>
<field name="from_account"/>
<field name="object_name"/>
<field name="def_to"/>
<field name="def_cc"/>
<field name="def_bcc"/>
<field name="def_subject"/>
<field name="use_sign"/>
<field name="file_name"/>
<button name="%(wizard_email_template_preview)d" string="Preview Template"
type="action" target="new" icon="gtk-zoom-fit"/>
</tree>
</field>
</record>
@ -170,14 +172,21 @@
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Templates">
<separator orientation="vertical"/>
<field name="name" select="1"/>
<field name="object_name" select="1"/>
<field name="def_to" select="1"/>
<separator orientation="vertical"/>
<field name="lang" select="1"/>
<field name="def_subject" select="1"/>
<field name="file_name" select="1"/>
<group col="13" colspan="4">
<field name="name" select="1"/>
<field name="object_name" select="1"/>
<field name="def_to" select="1"/>
<separator orientation="vertical"/>
<field name="lang" select="1"/>
<field name="def_subject" select="1"/>
<field name="file_name" select="1"/>
</group>
<newline/>
<group expand="0" string="Group by..." colspan="4" col="10">
<filter string="Account" domain="[]" context="{'group_by':'from_account'}" icon="terp-personal"/>
<separator orientation="vertical"/>
<filter string="Resource" domain="[]" context="{'group_by':'object_name'}" icon="terp-accessories-archiver"/>
</group>
</search>
</field>
</record>