[FIX] website_crm_partner_assign: add mark as spam to allow auto reassign

Withtout it, we cannot reassign a lead since we don't know if the partner
refuses because he don't want the lead or because it is a wrong / spam lead.
This commit is contained in:
Jeremy Kersten
2016-11-04 11:28:55 +01:00
parent af85529ce0
commit 227aaa572c
4 changed files with 22 additions and 8 deletions
@@ -4,6 +4,10 @@
<field name="name">No more partner available</field>
<field name="color">3</field>
</record>
<record model="crm.lead.tag" id="tag_portal_lead_is_spam">
<field name="name">Spam</field>
<field name="color">3</field>
</record>
<record id="email_template_lead_forward_mail" model="mail.template">
<field name="name">Lead Mass Mail</field>
<field name="model_id" model="ir.model" search="[('name', '=', 'crm.lead.forward.to.partner')]"></field>
@@ -12,7 +16,6 @@
<field name="email_from">${(user.email or '')|safe}</field>
<field name="subject">Fwd: Lead: ${ctx['partner_id'].name}</field>
<field name="body_html"><![CDATA[
<p>Hello,</p>
@@ -197,12 +197,12 @@ class CrmLead(models.Model):
lead.sudo().convert_opportunity(lead.partner_id.id)
@api.multi
def partner_desinterested(self, comment=False, contacted=False):
def partner_desinterested(self, comment=False, contacted=False, spam=False):
self.check_access_rights('write')
if contacted:
message = _('<p>I am not interested by this lead. I contacted the lead.</p>')
message = '<p>%s</p>' % _('I am not interested by this lead. I contacted the lead.')
else:
message = _('<p>I am not interested by this lead. I have not contacted the lead.</p>')
message = '<p>%s</p>' % _('I am not interested by this lead. I have not contacted the lead.')
partner_ids = self.env['res.partner'].search(
[('id', 'child_of', self.env.user.partner_id.commercial_partner_id.id)])
self.sudo().message_unsubscribe(partner_ids=partner_ids.ids)
@@ -210,8 +210,13 @@ class CrmLead(models.Model):
message += '<p>%s</p>' % comment
self.message_post(body=message, subtype="mail.mt_note")
values = {
'partner_assigned_id': False
'partner_assigned_id': False,
}
if spam:
tag_spam = self.env.ref('website_crm_partner_assign.tag_portal_lead_is_spam', False)
if tag_spam and tag_spam not in self.tag_ids:
values['tag_ids'] = [(4, tag_spam.id, False)]
if partner_ids:
values['partner_declined_ids'] = map(lambda p: (4, p, 0), partner_ids.ids)
self.sudo().write(values)
@@ -37,7 +37,9 @@ $('.desinterested_partner_assign_confirm').on('click',function(e){
.call("partner_desinterested",
[[parseInt($('.desinterested_partner_assign_form .assign_lead_id').val())],
$('.desinterested_partner_assign_form .comment_desinterested').val(),
$('.desinterested_partner_assign_form .contacted_desinterested').prop('checked')])
$('.desinterested_partner_assign_form .contacted_desinterested').prop('checked'),
$('.desinterested_partner_assign_form .customer_mark_spam').prop('checked'),
])
.then(function(){
window.location.href = '/my/leads';
});
@@ -495,8 +495,12 @@
<input type="text" name="comment" id="comment" class="form-control comment_desinterested"/>
</div>
<div class="form-group">
<label class="control-label" for="customer_contacted">Do you have contacted the customer?</label>
<input type="checkbox" name="customer_contacted" id="customer_contacted" class="contacted_desinterested"/>
<label class="control-label" for="contacted_desinterested">Do you have contacted the customer?</label>
<input type="checkbox" name="contacted_desinterested" id="contacted_desinterested" class="contacted_desinterested"/>
</div>
<div class="form-group">
<label class="control-label" for="customer_mark_spam">This lead is a spam</label>
<input type="checkbox" name="customer_mark_spam" id="customer_mark_spam" class="customer_mark_spam"/>
</div>
<div>
<span class="text-danger error_partner_assign_desinterested" style="display:none;">You need to fill up the next action and contact the customer before accepting the lead</span>