[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>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user