summaryrefslogtreecommitdiff
path: root/addons/im_livechat
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2019-08-20 08:12:32 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2019-08-20 08:12:32 +0000
commit5e3d49bc474271dfb7807fe4c21bbfb737e7c853 (patch)
tree7dc27bf6ad0e5fc46177c3d946317e62001e190c /addons/im_livechat
parent0f878e4839c36cd73fe8096ec1364f71af6bd8be (diff)
[FIX] im_livechat: livechat rating computes well
Open a livechat session between a visitor and a user That is, open the / controller as public user, and click, on the bottom right corner, on "Have a question ? Chat with us." Exchange at least one message to open the session From the visitor side, close the window. There is a proposal to rate the discussion Assign either the green face or the yellow one (The red one is a bit trickier) Now, on the user side, check the list view of LiveChat sessions Before this commit, the rating of those sessions were 0 This is because: The rating.rating < Many2One > mail.channel link is not a foreign key (rather, it is composed by char::res_model; Integer::res_id) and doesn't make the reciprocal field recompute, which in turn doesn't make our relevant field compute After this commit, the last_rating field field is recomputed and appear in the list view OPW 2052964 closes odoo/odoo#35830 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Diffstat (limited to 'addons/im_livechat')
-rw-r--r--addons/im_livechat/controllers/main.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/addons/im_livechat/controllers/main.py b/addons/im_livechat/controllers/main.py
index 14df16fb6c3..4e6b9e77b23 100644
--- a/addons/im_livechat/controllers/main.py
+++ b/addons/im_livechat/controllers/main.py
@@ -80,7 +80,6 @@ class LivechatController(http.Controller):
@http.route('/im_livechat/feedback', type='json', auth='public')
def feedback(self, uuid, rate, reason=None, **kwargs):
Channel = request.env['mail.channel']
- Rating = request.env['rating.rating']
channel = Channel.sudo().search([('uuid', '=', uuid)], limit=1)
if channel:
# limit the creation : only ONE rating per session
@@ -101,7 +100,11 @@ class LivechatController(http.Controller):
# if logged in user, set its partner on rating
values['partner_id'] = request.env.user.partner_id.id if request.session.uid else False
# create the rating
- rating = Rating.sudo().create(values)
+
+ channel.write({
+ 'rating_ids': [(0, False, values)]
+ })
+ rating = channel.rating_ids[0]
else:
rating = channel.rating_ids[0]
rating.write(values)