summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/services
AgeCommit message (Collapse)Author
2020-06-15[REF] mail, *: refactor messaging with OWLSébastien Theys
This commit is a significant rewriting of client-side discuss, chatter, chat window, and messaging menu using OWL. The behavior should be broadly the same, with some slight functional changes here and there. From a technical standpoint, the code of messaging is mainly organized in 2 main groups of modules: - models, which are logical entities that depict the client-side state of messaging as a whole. - components, which are in charge of displaying information from models. This refactoring also introduces new JS guidelines regarding folder structure (/static) and naming rules for JS modules. Community PR: https://github.com/odoo/odoo/pull/39023 Enterprise PR: https://github.com/odoo/enterprise/pull/6249 Task-1914207 This PR is a collaborative work by Alexandre, Julien, Sébastien and Xavier, with the precious help of Lucas to speed it up towards the end. closes odoo/odoo#39023 Related: odoo/enterprise#6249 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Co-authored-by: Alexandre Kühn <aku@odoo.com> Co-authored-by: Julien Giannone <jgi@odoo.com> Co-authored-by: Lucas Perais <lpe@odoo.com> Co-authored-by: Sébastien Theys <seb@odoo.com> Co-authored-by: Xavier Dubuc <xdu@odoo.com>
2020-06-12[IMP] web,*: properly define env in the frontendAaron Bohy
*bus,mail This commit extracts the common basis of the env to use both in the frontend and the backend. The public env now contains most of the features that were previously (only) in the webclient env. Moreover, the PublicRoot no longer uses the ServiceProviderMixin, such that services are only deployed once, in the (public) env. Owl components can now be defined in the website, and rely on a properly built env. Legacy widgets still works as they access services through the PublicRoot (via trigger_up) which redirects those requests to the env.
2020-06-12[IMP] *: update notifications to optional titleJulien Mougenot
closes odoo/odoo#52826 Related: odoo/enterprise#11084 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-05-22[FIX] mail: Load record form view with user idLucas Lefèvre
fixes #45425 closes odoo/odoo#51717 X-original-commit: a210d68af04490c0daa535e3151ed5edbd431898 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-05-05[REF] mail,hr: move openDMChatWindow to MailManagerAaron Bohy
It will be used by the Many2OneAvatarUser widget defined in the next commit.
2020-04-17[IMP] mail, sms, snailmail, test_mail_full: adapt mail.notificationSébastien Theys
The purpose is to have more common code for failure and notifications, with less override in `sms` and `snailmail`. task-2176017 closes odoo/odoo#44170 Related: odoo/enterprise#9140 Related: odoo/upgrade#918 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-03-10[FIX] mail: prevent hidden chat window close from opening home menuSébastien Theys
opw-2210274 closes odoo/odoo#47245 X-original-commit: ca695425a2b06ffba15d7063fb0b8ea994f751d6 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-02-25[FIX] mail: improve discuss new channel handling in mobileAlexandre Kühn
Revision on https://github.com/odoo/odoo/commit/8e5b6ab02aa95c204ea7bd241e6b8944d5972d43 Intent of commit above was to remove server-side synchronization of chat windows in mobile. To do so, it prevented sending RPCs for chat window state in mobile, in addition to not automatically adapt state of chat windows in mobile from longpolling notification. This implementation, while functionally working as intended, had disturbing intermediate logic that could potentially lead to bugs in the future. Specifically, on mobile, new channel did not directly trigger a re-render of discuss widgets. However, and thankfully, the related new message was triggering the rendering, so that UI correctly has channel and its notification. This commit simply improves code so that new channel always triggers a rendering, even in mobile, like before the commit above. Of course, to preserve the intent of not synchronizing chat windows in mobile, new detached channels must still not auto-open a chat window, and this commit clarifies this intended behaviour in the code. X-original-commit: 1046d063ca46aacb1e186599b5d4a02ef9c8e18d
2020-02-18[FIX] mail: no crash on receiving needaction on messaging not readyAlexandre Kühn
Before this commit, when receiving a needaction message while messaging was not ready (i.e. `/mail/init_messaging` not resolved), the web client crashed with the following error message: ``` TypeError: Cannot read property 'incrementMailboxCounter' of undefined ``` This happens due to reception of needaction message incrementing counter of mailbox Inbox, but this mailbox is only added after messaging is ready. This commit fixes the issue by directly adding inbox mailbox on starting the mail service. closes odoo/odoo#45442 X-original-commit: 741acb9f48f2d3542549791a8fd7d6fb318bc862 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-02-10[IMP] mail, test_mail, hr_holidays: remove obsolete out of officeSébastien Theys
The customizable "out of office" text was removed from the editable views as part of task-2053585, but some places in the code were still using it, even though it was never set anymore. This commit removes the obsolete code. Part of task-2171864 closes odoo/odoo#44968 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-02-05[IMP] mail: email channels duplicated notificationsmgh-odoo
This commit prevents sending a notification within Odoo when a message is posted from a mailing channel to a user whose notification management preference is set to "Handle by Emails". Task-ID 2033302 closes odoo/odoo#36000 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-11-30[IMP] mail: Unsychronize chat windows between mobile and desktopAdrien Dieudonne
Currently when you open, for example, 5 chat windows on the desktop, each of those windows will be opened on mobile as well. The big issue with that is that I have to shut down all windows before starting to work on the application. To make things simple, you have to explicitly open chat window to make it appears on mobile. Synchronization is blocked in both direction. We don't update the chat window state on the server and we no longer consider notifications (bus) about it. Tests were added in enterprise. Task ID: 1891952 closes odoo/odoo#41052 Related: odoo/enterprise#6943 Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2019-10-14[FIX] mail: discuss unstar allAlexandre Kühn
Before this commit, when clicking on "Unstar All" from Discuss 'Starred' mailbox, it crashes with following error: ``` TypeError: unstar_all() takes 1 positional argument but 2 were given ``` This commit fixes this issue closes #37994 closes odoo/odoo#38738 X-original-commit: ec330d1668640d3ae75e23a70695006a63dbe217 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-09-24[MERGE] forward port branch saas-12.4 up to 9ed4872ea03Christophe Simonis
closes odoo/odoo#37372 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-18[FIX] mail: no wait init_messaging before loading webclientAlexandre Kühn
Before this commit, discuss widgets had to wait for the route `mail/init_messaging`. This behaviour slowed down the loading of the web client. This commit solves the issue by rendering discuss widgets even when `mail/init_messaging` hasn't been resolved. For instance, the messaging menu displays a spinner until messaging becomes ready. Task-Id 2072835 closes odoo/odoo#37031 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-09-13[MERGE] forward port branch saas-12.4 up to fe59754c520Christophe Simonis
closes odoo/odoo#36721 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-04[MERGE] forward port branch 12.0 up to 638eac9baeaChristophe Simonis
2019-09-03[FIX] bus, mail: correctly synchronize document chat windowsAlexandre Kühn
Before this commit, there could be an infinite loop when changing the chat window state of a document chat window. This is caused when mutiple tabs overwrite the chat window state with a different value everytime, resulting to an infinite loop. Accross multiple tabs, `setItem` and `onStorage` are not synchronous. That's why tabs should communicate through local storage events instead of actual value in the local storage. To illustrate the issue, suppose there are 2 tabs (T1 and T2) with one document chat windows (C) and the following user interactions: - T1 and T2 both have C open - on T1, user folds C - on T2, user folds C Now let's add an example of local storage (LS) logics that could apply from above example: - T1 and T2 both have C open - on T1, user folds C [1] T1 writes 'C folded' in LS - on T2, user folds C [2] T2 writes 'C folded' in LS [3] T2 detects 'C folded' in LS (from [1]) => T2 writes 'C folded' in LS [4] T1 detects 'C folded' in LS (from [2]) => T1 writes 'C folded' in LS [5] T1 detects 'C folded' in LS (from [3]) => T1 writes 'C folded' in LS [6] T2 detects 'C folded' in LS (from [4]) => T2 writes 'C folded' in LS etc... This scenario could have been easily prevented by not writing on local storage when the chat window state has not changed. However, this wouldn't fix this scenario that also introduces an infinite loop: - T1 and T2 both have C open - on T1, user folds C [1] T1 writes 'C folded' in LS - on T2, user folds C [2] T2 writes 'C folded' in LS - on T2, user unfolds C [3] T2 writes 'C unfolded' in LS [4] T2 detects 'C folded' in LS (from [1]) => T2 writes 'C folded' in LS [5] T1 detects 'C unfolded' in LS (from [3]) => T1 writes 'C unfolded' in LS [6] T2 detects 'C unfolded' in LS (from [5]) => T2 writes 'C unfolded' in LS [7] T1 detects 'C folded' in LS (from [4]) => T1 writes 'C folded' in LS [8] T2 detects 'C folded' in LS (from [7]) => T2 writes 'C folded' in LS [9] T1 detects 'C unfolded' in LS (from [6]) => T1 writes 'C folded' in LS etc... This commit fixes the infinite loop issue: - by turning local storage read during cross-tab communication into local storage event read instead. This should prevent race conditions based on read/write operations in local, since their order is not guaranteed accros tabs. - by isolating document chat window state to their own local storage entry. This should prevent a tab from notifying a chat window state that it didn't change, which may also result in an infinite loop. Some tests were adapted from the changes above. Also, some tests did pass thanks to local storage being mocked by a ram storage: the handler `_onStorage` should have been called, but it didn't because it was registered on the actual local storage instead of the ram storage. In order to make tests pass again, the following additional changes were required: - Cross-tab bus service now exports the unique tab ID with `getTabId`. - document thread entries in local storage now track the tab ID, so that self-tab ignore their own local storage writes. Task-Id 2034997 Closes #36177
2019-08-14[FIX] mail: receive message then delayed needaction notificationsAlexandre Kühn
Before this commit, when a user received a needaction notification on a message already stored locally, it crashed with this error: `TypeError: Cannot read property 'getThreadIDs' of undefined` This is caused by `addMessage` returning a Promise not resolved with the message when the message is not new. The returned promise should always be resolved with the message, in order to be consistent. closes odoo/odoo#35724 Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
2019-08-14[FIX] mail: no crash on opening chat window twiceAlexandre Kühn
Revision on https://github.com/odoo/odoo/commit/e8f7770a13d6ddc1cb8ec1bcebcb22e21962ba52 Commit above fixes an issue with chat windows being open twice. It fixed the issue by aborting opening a chat window in case a chat window is already being open. Opening chat window may be a slow process, due to requiring fetching some messages beforehand. This operation is necessary in order to check whether the user has access to messages or not, and prompt an error message without opening the chat window in the latter case. The fix did not respect the specs of the method `openThread`: it pre-emptively returned nothing, instead of returning a resolved promise. Because of this, it crashed on `undefined.then()`. Task-ID 2053095 closes odoo/odoo#35722 Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
2019-08-12[FIX] mail: register thread window after append in DOMAlexandre Kühn
Before this commit, we may have the following error: `TypeError: Cannot read property 'html' of undefined` This happened in the following scenario: Terminology: - in multi-tab environment, there is a master tab and slave tabs - master tab fetches notifications from the server and forwards them to slave tabs State: - 2 logged-in users: Michell & Marc - Mitchell has open 2 browser tabs - Mitchell has a pinned private conversation with Marc Steps: - Mitchell has focus on a slave tab - Marc posts several messages to Mitchell in very quick succession => Mitchell gets crash error above. This issue is caused by chat window being registered in mail manager while it has not been mounted to DOM. On receiving 2nd new message, it has to re-render chat window header in order to update displayed unread counter. However, this fails due to chat window having no DOM node yet. This commit solves the issue by mounting chat window to DOM before being registered in mail manager. That way, on receiving 2nd new message, it does not trigger a re-render on chat window that is about to be mounted to DOM, since it has not been registered yet. Note that the displayed unread counter will be correct, because it uses the up-to-date unread counter on mount. Task-ID 2050108 closes odoo/odoo#35601 Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
2019-08-06[MERGE] forward port branch saas-12.2 up to 9e74730a26bChristophe Simonis
2019-08-06[MERGE] forward port branch 12.0 up to ff9ddfdacc9Christophe Simonis
2019-08-21[MERGE] forward port branch saas-12.4 up to f26de445e55Christophe Simonis
2019-08-19[IMP] website_livechat : allow to send chat request to a website_visitorDavid Beguin
This commit allows a livechat operator to send a chat request to a connected and available website_visitor. A visitor is considered as connected if his last tracked website.page request was within the last 5 minutes. A visitor is available if he doesn't have an active livechat conversation (mail_channel with type = livechat). - If another operator sent him a chat request - Or if the visitor asked himself to speak with an operator (via the normal and existing flow) A livechat conversation is active while the visitor haven't left the conversation. An operator cannot leave a livechat conversation, only the visitor can. The flow to send a chat request: - On the visitor view (tree or form), operator click on 'send chat request' (button or livechat icon) - A empty conversation with the visitor pops up at operator side. - While the operator didn't send a message, the visitor won't see the conversation. - The operator can type a message to the user - If the operator close the chat without sending any messages, the chat request AND the mail_channel are both deleted. In this case, the visitor is then available to send him a new chat request. - If the operator send a message, at the visitor's next action (page navigation on pages that allows livechat, based on livechat rules), the conversation will pop up at visitor side, using the livechat button widget. The visitor won't be able to request a livechat conversation with an operator until he leaves the chat requested by the operator. - Once the visitor leaves (with or without rating) the conversation : - the operator is notified that the visitor has left the conversation - the chat request is deleted to keep the chat request table clean and minimal - the livechat conversation if set to inactive. - The visitor is now available again to send him a chat request. This feature uses the already existing livechat_session cookie mechanism, so no further code modification was needed to make this work. It's directly integrated is existing livechat flow. The chat_request model is only useful to quickly check if a visitor has a chat request and to send the livechat conversation info to the visitor via the livechat_session cookie. This commit also add a website_visitor banner info on discuss view : To be able to quickly see all the relevant information of a website visitor while talking with in discuss view, a fixed banner have been added. Only the discuss view will benefit from this because detached chatter window is to small to display such banner. Task ID: 34624 PR #2028059
2019-08-14[MERGE] forward port branch saas-12.4 up to 98a55917a60Christophe Simonis
2019-08-05[IMP] mail, test_mail: new 'History' mailbox in DiscussNikunj Ladava
This commit adds a new mailbox in the Discuss app called 'History'. Messages that have been marked as read are moved to 'History'. Notifications are required to link history messages to users. So notifications are now deleted after they are more tha 6 months old. This means History mailbox keeps less than 6 months old messages. Note that this feature only works when user notifications are handled in Odoo. This can be set in the user preferences, under the "Notification Management" section. Task-ID 402597
2019-07-23[MERGE] Forward port of 12.0 to saas-12.2 up to 5e4c1b370123deeMartin Trigaux
2019-08-01[FIX] mail: use correct translation methodkarol1985
_() is in python _t() is for javascript closes odoo/odoo#35329 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-24[MERGE] Forward port of saas-12.2 to saas-12.3 up to 860ab5a1c28baMartin Trigaux
closes odoo/odoo#35119 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-16[FIX] mail: auto-update out-of-office info on im_status changeAlexandre Kühn
Before this commit, chat window's out-of-office info did not change when direct partner's `im_status` is/was on 'leave'. Users had to reload page to see updated out-of-office info. Task-ID 2007663
2019-07-16[FIX] mail: notify other tabs on document thread message postAlexandre Kühn
Before this commit, most new messages added to the mail manager were handled as if recently posted from a document thread. As a result, it was frequently setting a new item in the local storage to notify other tabs from these new messages. The intent of this behaviour is to notify other tabs of newly posted messages in a document thread, without using a longpolling notification. That means this logic should only apply on messages that have been recently posted on a document thread. Sometimes, this issue was breaking the local storage on Firefox. It showed the error message "Quota Exceeded Error" whenever `setItem` was used, even when items were removed beforehand. The capacity of the storage was only a few Kbs on this domain, far from reaching the maximum capacity. We think that this error comes from the concurrent `setItem` on multiple tabs, but this is very hard to reproduce. This commit fixes the issue by limiting the `setItem` to the tab that really posted the message. Tests have been adapted in order to pass only with this fix.
2019-07-12[MERGE] Forwardport of saas-12.2 to saas-12.3 up to 01365a3f625c9e7Martin Trigaux
closes odoo/odoo#34747 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-10[FIX] mail: show old messages /leave w/o reloadNicolas Lempereur
Before this commit, if we had a livechat channel with a user and: - in backend use command "/leave" to leave and unpin conversation - [do not reload the page (or there is no issue)] - then the user sends a new message The chat window opens just with the new message. Fetched previous messages are ignored due to being already in the mail manager, and links between these messages and the threads were never updated. With this commit, when fetching messages that are already in the mail manager, these messages are linked again to threads. This commit also fixes an issue in which messages moderated with status "accepted" were not correctly removed from the moderation mailbox. This problem occurred after the fix on re-linking messages to threads. opw-2031270 closes #34761 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-06-27[MERGE] forward port branch saas-12.2 up to 465909f0fdeChristophe Simonis
2019-06-27[MERGE] forward port branch 12.0 up to cd21c016b06Christophe Simonis
2019-06-24[FIX] mail: keep chat window hidden on receiving new messageAlexandre Kühn
Before this commit, when receiving a new message from a hidden chat window, it was making it visible. Because of this, if we had focus on any other window, the focus was lost. Even more annoying, if we had focus on the left-most visible chat window, it moved to hidden menu, so that new chat window takes its place. This commit fixes the issue by keeping new chat windows hidden on receiving new messages, in case there is not enough available space. Task-ID 2026101 closes odoo/odoo#34291 Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
2019-07-18[IMP] mail: Add simple partner notificationRémi Rahir
2019-06-03[MERGE] forward port branch saas-12.2 up to 995aa1685eeChristophe Simonis
2019-08-09[FIX] mail: notify other tabs on document thread message postAlexandre Kühn
Before this commit, most new messages added to the mail manager were handled as if recently posted from a document thread. As a result, it was frequently setting a new item in the local storage to notify other tabs from these new messages. The intent of this behaviour is to notify other tabs of newly posted messages in a document thread, without using a longpolling notification. That means this logic should only apply on messages that have been recently posted on a document thread. Sometimes, this issue was breaking the local storage on Firefox. It showed the error message "Quota Exceeded Error" whenever `setItem` was used, even when items were removed beforehand. The capacity of the storage was only a few Kbs on this domain, far from reaching the maximum capacity. We think that this error comes from the concurrent `setItem` on multiple tabs, but this is very hard to reproduce. This commit fixes the issue by limiting the `setItem` to the tab that really posted the message. Tests have been adapted in order to pass only with this fix. note: backport of 12.2 4bde721f9 opw-2031960 closes #35588 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-07-29[MERGE] forward port branch saas-12.4 up to cda4f3c308cChristophe Simonis
2019-07-15[MERGE] Forward port of saas-12.4 to master up to 1f5a4649a67908Martin Trigaux
closes odoo/odoo#34850 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-06-27[MERGE] forward port branch saas-12.4 up to 5e81b18e24aChristophe Simonis
2019-06-17[IMP] *: remove 'view_type' on window actions.Hiral Bhavsar
The old tree views don't really exist anymore, this odd pseudo-flag to dispatch between "list" and "tree" tree views has no reason to remain. Task 1937686 closes odoo/odoo#31243 Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-05-24[FIX] mail: hide im_status RPCNicolas Martinelli
If the `/longpolling/im_status` route is slow to respond, the UI might be blocked while there is no good reason to do it. closes odoo/odoo#33643 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2019-05-20[FIX] bus, mail: fetch im_status with '/longpolling/im_status'Alexandre Kühn
Before this commit, mail status manager was regularly fetching `im_status` of partners with `this._rpc()`. This used the main thread worker, so it may be overloaded because of that. To mitigate this issue, mail status manager now uses a new route `/longpolling/im_status` to fetch `im_status` of partners using the longpolling thread worker. closes odoo/odoo#33238 Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2019-05-20[FIX] im_support, mail: message with odoobot as authorAlexandre Kühn
Before this commit, the `author_id` of a message with odoobot was `"ODOOBOT"`. This leads to some issues due to `author_id` being considered as an array `[partnerID, name]`. Because of this, mail status manager was registering a partner with ID `"O"` (1st char of `"ODOOBOT"`) for fetching its `im_status`. Its `im_status` was never updated, since no partner has such ID. However, the mail status manager kept this partner flagged with missing `im_status` and still attempted to fetch its `im_status`, indefinitely. This commit fixes the issue by turning `author_id` of a message with odoobot into arrray `["ODOOBOT", "ODOOBOT"]`. That way, `author_id` of a message is always an array, and the `im_status` of `"ODOOBOT"` is no longer fetched.
2019-02-22[MERGE] forward port branch saas-12.1 up to 0f4abc5c228Christophe Simonis
2019-03-06[REF] mail: adapt code after jQuery updateVincent Schippefilt
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2019-02-14[FIX] mail: enable seen feature only on direct chatsAlexandre Kühn
Revision on https://github.com/odoo/odoo/commit/844fb2b51ea7cfa557b19466c0a53dde19433e7a There were performance issue with the seen feature in multi- user channnels, therefore it has been disabled for them. As a result, only direct chats have this feature.