diff options
| author | David Beguin <dbe@odoo.com> | 2019-09-24 12:39:49 +0000 |
|---|---|---|
| committer | David Beguin <dbe@odoo.com> | 2019-09-24 13:25:50 +0000 |
| commit | 4a37beeff641f6cf9206be80c0aabd7e7b9f6152 (patch) | |
| tree | 8536a657df553b6eb96d7a16f105a8e54182fd9a | |
| parent | 33f5bbc7d0808ac61ddd2432aded7cbf66a34e50 (diff) | |
[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
| -rw-r--r-- | addons/website_livechat/models/mail_channel.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/addons/website_livechat/models/mail_channel.py b/addons/website_livechat/models/mail_channel.py index 2eb94f89f8d..4152de2cfd5 100644 --- a/addons/website_livechat/models/mail_channel.py +++ b/addons/website_livechat/models/mail_channel.py @@ -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.""" |
