[FIX] crm, mail: Convert to opportunity in mail notification

The button "Convert to opportunity" in the mail notifications
sent when posting a message on an opportunity just coudln't
work as it attempted to call the `convert_opportunity`
method without one of its required method parameter.

opw-680017
This commit is contained in:
Denis Ledoux
2016-06-08 17:15:15 +02:00
parent 876b893a53
commit 3ddb446b3b
3 changed files with 7 additions and 4 deletions
+3 -2
View File
@@ -974,11 +974,12 @@ Update your business card, phone book, social media,... Send an email right now
def _notification_get_recipient_groups(self, cr, uid, ids, message, recipients, context=None):
res = super(crm_lead, self)._notification_get_recipient_groups(cr, uid, ids, message, recipients, context=context)
lead = self.browse(cr, uid, ids[0], context=context)
won_action = self._notification_link_helper(cr, uid, ids, 'method', context=context, method='case_mark_won')
lost_action = self._notification_link_helper(cr, uid, ids, 'method', context=context, method='case_mark_lost')
convert_action = self._notification_link_helper(cr, uid, ids, 'method', context=context, method='convert_opportunity')
convert_action = self._notification_link_helper(cr, uid, ids, 'method', context=context, method='convert_opportunity', partner_id=lead.partner_id.id)
lead = self.browse(cr, uid, ids[0], context=context)
if lead.type == 'lead':
res['group_sale_salesman'] = {
'actions': [{'url': convert_action, 'title': 'Convert to opportunity'}]
+2 -1
View File
@@ -1,4 +1,5 @@
import base64
import json
from operator import itemgetter
import psycopg2
import werkzeug
@@ -187,7 +188,7 @@ class MailController(http.Controller):
Model = request.env[model]
try:
record = Model.browse(int(res_id)).exists()
getattr(record, method)()
getattr(record, method)(**json.loads(kwargs.get('params', {})))
except:
return self._redirect_to_messaging()
return werkzeug.utils.redirect('/mail/view?%s' % url_encode({'model': model, 'res_id': res_id}))
+2 -1
View File
@@ -4,6 +4,7 @@ import base64
import datetime
import dateutil
import email
import json
import lxml
from lxml import etree
import logging
@@ -560,7 +561,7 @@ class MailThread(models.AbstractModel):
link = '/mail/workflow?%s' % url_encode(params)
elif link_type == 'method':
method = kwargs.pop('method')
params = dict(base_params, method=method, params=kwargs)
params = dict(base_params, method=method, params=json.dumps(kwargs))
link = '/mail/method?%s' % url_encode(params)
elif link_type == 'new':
params = dict(base_params, action_id=kwargs.get('action_id'))