[FIX] website_livechat : fix history in discuss visitor banner
Adding a string element to a list with += is not adding the element to the list
but is instead adding every single character of the string as an element to the list.
Building a string using a join method was resulting to an recent history displayed like
H > O > M > E > ( > 8 > : > 4 > 2 > )
--> Should be : HOME (8:42) > Contact Us (8:45)
Apart from that, since the tracking is now ordered by visit_datetime DESC,
to have a chronological order, we need to reverse the list of last visited pages
to have something like :
Home (12:43) > About us (12:45) > Contact Us (12:52)
instead of :
Contact Us (12:52) > About us (12:45) > Home (12:43)
Task ID: 2076190
PR #37340
This commit is contained in:
@@ -50,13 +50,8 @@ class MailChannel(models.Model):
|
||||
:param visitor: website.visitor of the channel
|
||||
:return: arrow separated string containing navigation history information
|
||||
"""
|
||||
history = []
|
||||
for page in visitor.website_track_ids:
|
||||
if page.page_id:
|
||||
history += page.page_id.name + ' (' + page.visit_datetime.strftime('%H:%M') + ')'
|
||||
if len(history) == 3:
|
||||
break
|
||||
return ' → '.join(history)
|
||||
recent_history = self.env['website.track'].search([('page_id', '!=', False), ('visitor_id', '=', visitor.id)], limit=3)
|
||||
return ' → '.join(visit.page_id.name + ' (' + visit.visit_datetime.strftime('%H:%M') + ')' for visit in reversed(recent_history))
|
||||
|
||||
def close_livechat_request_session(self, type='leave', **kwargs):
|
||||
""" Set deactivate the livechat channel and notify (the operator) the reason of closing the session."""
|
||||
|
||||
Reference in New Issue
Block a user