[FIX]crm_channel: email template improvment

bzr revid: dle@openerp.com-20130620151842-06bzm9ru0ez2pej5
This commit is contained in:
Denis Ledoux
2013-06-20 17:18:42 +02:00
parent 7be4614731
commit f650c896e2
3 changed files with 38 additions and 39 deletions
@@ -10,25 +10,29 @@
<field name="subject">Fwd: Lead: ${ctx['partner_id'].name}</field>
<field name="body_html"><![CDATA[
Hello ${ctx['partner_id'].name},
</br>
</br>
<p>Hello,</p>
<p>We have been contacted by those prospects that are in your region. Thus, the following leads have been assigned to ${ctx['partner_id'].name}:</p>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">Some leads have been assigned to you. Here are the various leads we propose: </blockquote></br></br>
<b>
<ol>
% for lead in ctx['partner_leads']:
<li><a href="${lead.lead_link}">${lead.lead_id.name or 'Subject Undefined'}</a>, ${lead.lead_id.contact_name or 'Contact Name Undefined'}, ${lead.lead_id.country_id and lead.lead_id.country_id.name or 'Country Undefined' }, ${lead.lead_id.email_from or 'Email Undefined'}, ${lead.lead_id.phone or 'Phone Number Undefined'} </li></br>
<li><a href="${lead.lead_link}">${lead.lead_id.name or 'Subject Undefined'}</a>, ${lead.lead_id.contact_name or 'Contact Name Undefined'}, ${lead.lead_id.country_id and lead.lead_id.country_id.name or 'Country Undefined' }, ${lead.lead_id.email_from or 'Email Undefined'}, ${lead.lead_id.phone or ''} </li></br>
% endfor
</ol>
</b>
</br>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">Connect you to your <b><a href="${object.get_portal_url()}">Partner Portal</a></b> to see leads details.</blockquote>
<p>Please connect to your <a href="${object.get_portal_url()}">Partner Portal</a> to get details. On each lead are two buttons on the top left corner that you should press after having contacted the lead: "I'm interested" & "I'm not interested".</p>
</br>
Thanks,</br>
Account Manager
<p>If you did not contact the lead after 4 weeks (20 days), the lead will be send to another partner.</p>
<p>Thanks,</p>
<pre>
${ctx['partner_id'].user_id and ctx['partner_id'].user_id.signature or 'The OpenERP Team'}
</pre>
% if not ctx['partner_id'].user_id:
PS: It looks like you do not have an account manager assigned to you, please contact us.
% endif
]]></field>
</record>
</data>
@@ -91,10 +91,7 @@ class crm_lead_forward_to_partner(osv.TransientModel):
if not (record.forward_type == 'single'):
no_email = []
for lead in record.assignation_lines:
if not lead.partner_assigned_id:
raise osv.except_osv(_('Assignation Error'),
_('Some leads have not been assigned to any partner so assign partners manualy'))
if not lead.partner_assigned_id.email:
if lead.partner_assigned_id and not lead.partner_assigned_id.email:
no_email.append(lead.partner_assigned_id.name)
if no_email:
raise osv.except_osv(_('Email Error'),
@@ -105,16 +102,17 @@ class crm_lead_forward_to_partner(osv.TransientModel):
partners_leads = {}
for lead in record.assignation_lines:
partner = record.forward_type == 'single' and record.partner_id or lead.partner_assigned_id
lead_details = {
'lead_link': lead.lead_link,
'lead_id': lead.lead_id,
}
partner = record.forward_type == 'single' and record.partner_id or lead.partner_assigned_id
partner_leads = partners_leads.get(partner.id)
if partner_leads:
partner_leads['leads'].append(lead_details)
else:
partners_leads[partner.id] = {'partner': partner, 'leads': [lead_details]}
if partner:
partner_leads = partners_leads.get(partner.id)
if partner_leads:
partner_leads['leads'].append(lead_details)
else:
partners_leads[partner.id] = {'partner': partner, 'leads': [lead_details]}
for partner_id, partner_leads in partners_leads.items():
local_context['partner_id'] = partner_leads['partner']
local_context['partner_leads'] = partner_leads['leads']
@@ -124,17 +122,17 @@ class crm_lead_forward_to_partner(osv.TransientModel):
self.pool.get('crm.lead').message_subscribe(cr, uid, lead_ids, [partner_id], context=context)
return True
def action_clean_lines(self, cr, uid, ids, context=None):
record = self.browse(cr, uid, ids[0], context=context)
invalid_lines = []
for line in record.assignation_lines:
if not line.partner_assigned_id:
invalid_lines.append((2, line.id))
self.write(cr, uid, ids[0], {'assignation_lines': invalid_lines}, context=context)
model, action_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm_channel', 'action_crm_send_mass_forward')
action = self.pool[model].read(cr, uid, action_id, context=context)
action['res_id'] = ids[0]
return action
# def action_clean_lines(self, cr, uid, ids, context=None):
# record = self.browse(cr, uid, ids[0], context=context)
# invalid_lines = []
# for line in record.assignation_lines:
# if not line.partner_assigned_id:
# invalid_lines.append((2, line.id))
# self.write(cr, uid, ids[0], {'assignation_lines': invalid_lines}, context=context)
# model, action_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'crm_channel', 'action_crm_send_mass_forward')
# action = self.pool[model].read(cr, uid, action_id, context=context)
# action['res_id'] = ids[0]
# return action
def get_portal_url(self, cr, uid, ids, context=None):
portal_link = "%s/?db=%s" % (self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url'), cr.dbname)
@@ -144,7 +142,6 @@ class crm_lead_forward_to_partner(osv.TransientModel):
'forward_type': fields.selection([('single', 'a single partner: manual selection of partner'), ('assigned', "several partners: automatic assignation, using GPS coordinates and partner's grades"), ], 'Forward selected leads to'),
'partner_id': fields.many2one('res.partner', 'Forward Leads To'),
'assignation_lines': fields.one2many('crm.lead.assignation', 'forward_id', 'Partner Assignation'),
'show_mail': fields.boolean('Show the email will be sent'),
'body': fields.html('Contents', help='Automatically sanitized HTML contents'),
}
@@ -16,7 +16,7 @@
<group>
</group>
</group>
<button name="action_clean_lines" string="Clean Unassigned" type="object" attrs="{'invisible': [('forward_type', 'in', ['single',False])]}"/>
<!-- <button name="action_clean_lines" string="Clean Unassigned" type="object" attrs="{'invisible': [('forward_type', 'in', ['single',False])]}"/> -->
<field name="assignation_lines" attrs="{'invisible': [('forward_type', 'in', ['single',False])]}">
<tree create="false" editable="bottom">
<field name="lead_id" readonly="1" on_change="on_change_lead_id(lead_id)"/>
@@ -25,10 +25,8 @@
<field name="partner_location" readonly="1"/>
</tree>
</field>
<field name="show_mail" />
<label for="show_mail" />
<notebook colspan="4" attrs="{'invisible': [('show_mail', '=', False)]}">
<page string="Body">
<notebook colspan="4" groups="base.group_no_one">
<page string="Email Template">
<field name="body" readonly="1"/>
</page>
</notebook>