summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/services
AgeCommit message (Collapse)Author
2019-03-06[REF] web: 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-03-06[IMP] web: don't swallow errors in async handlersAaron Bohy
This commit adds a 'guardedCatch' function to the Promise API. This function has to be used when we don't want to swallow real errors (crashes), like 'catch' does (i.e. basically all the time in Odoo). When the promise has been rejected because of a real error, the rejected Promises chain bubbles up to the top and triggers the 'unhandledrejection' event (triggered on all browsers thanks to the unhandled-rejection-polyfill lib). We then add a listener on that event to display real errors with the CrashManager. 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-01-28[MERGE] forward port branch saas-12.1 up to d3b8422c9c4Christophe Simonis
closes odoo/odoo#30614
2019-01-18[MERGE] forward port branch 12.0 up to f854e01a983Christophe Simonis
2019-01-11[FIX] web: add exponential backoff strategy for lost connectionGéry Debongnie
Before this commit, the web client had a naive strategy to handle lost connections: it tried to poll the server every 2 seconds until a rpc succeeds. This works quite well from the perspective of the user, but may be a problem from the perspective of the server. If a server is down for a longish period, then each users active tabs will then perform a request every 2 seconds. This means that the server will be progressively hammered by many requests, which will clutter the logs, and make it more difficult to gracefully recover. With this commit, we simply exponentially increase the delay each time, and add a little jitter to give a better distribution. closes odoo/odoo#30136
2018-12-07[REF] web: move ControlPanel inside controllers/actionsGéry Debongnie
This branch introduces a large-scale reorganization of the component tree generated by the web client. The short version is that now, the control panel is a child of the view controller and no longer a sibling. Graphically (and simplified), we go from this: webClient / | \ ... ... actionManager / \ controlPanel viewController / \ to this: webClient / | \ ... ... actionManager | viewController / | \ ControlPanelController / \ CPRenderer CPModel The motivation is that this work moves the code where it should be. Before this commit, it was kind of weird to have code in the controllers to render buttons outside of their root node (in renderButtons). Also, the action manager had to take care of coordinating search view states between view transitions. So, this work simplifies the code. It also makes it easier to extend. We see day after day that Odoo needs to take care of more complex UI needs, and in many cases, these needs were quite difficult to implement (we prefer spaghettis in our plates, not in our code). The changes in this branch should open the way to implement these features. For example, - it will now be easy to add the possibility of views (for example, the search view or a new ControlPanel view) to add custom buttons (of type action or object) in the control panel. - Another need will be to serialize/ restore the state of the search view across action boundaries (needed by the dashboard). - Another example is the possibility for views to customize easily the presence/absence of sub menus (filters/groupbys/favorites/ time range/...) - Another need is an easier way for views/client action to customize their control panel. This commit also contains a large rewrite of the search view (so it is more inline with our architecture and easier to maintain). Part of task 1893568 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com>
2018-12-11[FIX] *: JS doc/docstring errors & warningsXavier Morel
closes odoo/odoo#29439
2018-10-24[FIX] web: copy traceback in firefoxNicolas Lempereur
Same issue as in 902e484f1. In some browser (eg. firefox) the container parameter of ClipboardJS is needed if the focus is inside the modal so the copy work. See information on: https://github.com/zenorocha/clipboard.js/pull/368 opw-1902040 closes #28117
2018-10-22[MERGE] forward port branch saas-11.4 up to 3c108977c1eChristophe Simonis
2018-10-10[FIX] calendar: notifications may appearChristophe Matthieu
Following the transformation into notification service, performed by commit 07cd24b1ecf3ab8edd3fffbf2fcd3a3e685f357c, calendar has been forgotten.
2018-09-14[MERGE] forward port branch saas-11.4 up to 6c103589c15Christophe Simonis
2018-09-13[FIX] web: correct mobile screen size.Hiral Bhavsar
Revision on https://github.com/odoo/odoo/commit/d91ec258e6a31153beb9eb16cfe8f916546b7688 The commit above reverts a commit when we were using bootstrap 3. The equivalent of XS in bootstrap 3 is SM in bootstrap 4. So the correct revert with bootstrap 4 is to use SM. Also removing useless style on 'o_mobile_menu_opened'. Closes #26434
2018-09-10[FIX] web: ajax must return a promise with abort methodChristophe Matthieu
Remove part in service_mixins who hide this error. Queries must be able to be canceled for better performance. Also in the case of longpolling, if the request is not canceled, wait for a server message or the maximum time (30 sec) to add or delete channels.
2018-08-10[MERGE] forward port branch saas-11.4 up to edd586002e9Christophe Simonis
2018-08-09[IMP] web: remove useless service nameChristophe Matthieu
We use the registry keys as name for the services.
2018-08-07[FIX] Crash Manager - Clipboard JS reference updatedDavid Beguin
The instanciation of the clipboard in the crash manager was not updated in the fix that upgraded the clipboard.js
2018-08-02Revert "[IMP] web: use burger menu for tablet in vertical mode"Adrien Dieudonne
This reverts commit 4e5f826ce53b9e4cb73eea77935ea82e81ac66b9 for two reasons: 1) A lot of people are working with splitted desktop screen and will see the view switcher/search as on mobile: it's not efficient. Only the burger menu should have been visible for the tablets, not the other mobile features. 2) When you switch between vertical mode and H mode, we don't want to change the mobile mode because widgets aren't reinstantiated and some features don't work. For example, the burger menu is broken if you switch from H mode to V mode. Task-1869468
2018-07-27[REF] web, *: BS4, update JS media queriesqsm-odoo
* website_quote, website_sale
2018-07-27[REF] web, *: BS4, adapt use of tooltip/popover.jsqsm-odoo
2018-07-13[IMP] web: use builtin crash manager hooks for special handlingXavier Morel
* having a special case for session expiration seems unnecessary when the CM specifically supports hooking on the exception name * and properly implement the special handling of HTTP 504 (Gateway Timeout) from #24854 using that same hook
2018-07-02[REF] mail: JS mail refactoringAlexandre Kühn
---------------------- Summary ---------------------- The purpose of this commit is to improve the JS code of the `mail` module. It applies the new coding guidelines and makes some changes on the design of some modules, such as the old ChatManager module. Here is a short summary of the changes that have been made: 1. New coding guidelines - snake_case to camelCase - prefix private attributes and methods with '_' - jsdoc on most methods - one class per module 2. Rename/Merge some classes - 'chat manager' becomes 'mail manager' (internal) and 'mail service' (external) - 'chat window manager' is now included in mail manager - 'thread' widget now named 'thread widget' 3. New model abstraction for mail objects: - modules 'mail.model.*' - modeling: 0..1 0..1 * * ThreadWindow <------> Thread <-------> Message / \ / \ Thread With Cache Document Thread / | \ / | \ Mailbox Channel Support Channel | | DM - Thread: the superclass of threads. - ThreadWindow: the window component of a thread. - Message: mail objects representing messages. - Thread With Cache: threads that can be used with search view (Discuss app compatible). - Document Thread: represents the thread part of a chatter. - Mailbox: represents what was previously called 'static' channel, e.g. 'Inbox'. - Channel: mail objects representing channels, including livechat. - DM: special kind of Channel for 1:1 communication in the backend. - Support Channel: special channel for im_support module. This new modeling approach let us easily add features on all threads, such as the possibility to put any thread in a small window. ---------------------- Known issues ---------------------- [Already Present in Master] 1. When the Discuss app is in the background with 'Inbox' as the selected Thread, when clicking on a document thread preview in the messaging menu of the systray, the rainbow man appears. 2. When a document with the chatter is in the background, when receiving an inbox notification from this document thread, the document thread is automatically marked as read, which removes the notification right away. 3. Sometimes, opening a DM window from the "blank" thread window does not work. 4. Reply-to feature on Inbox is not working: no message is sent in the document thread. 5. On the first login of admin user with demo data, the inbox counter is wrong (it displays 6, instead of 3). Explanation after investigation: > On page load, it fetches the correct number of Inbox messages (3), but the server notifies of 3 needaction messages right away, so it wrongly assumes these are new needaction messages. > Not possible for web client to detect that these messages should not increment the Inbox counter while keeping same API. 6. Notifications for new document thread messages only work when the user sets 'handle with Odoo' for the Notification Management in the preferences. > due to notifications on the longpoll bus for document thread messages that come from needaction notifications. > requires server-side changes to send notification on the longpoll bus to mentionned user. [New] 7. When receiving a message on a unjoined channel, thread window flickers ('open' > 'close' > 'open') Explanation after investigation: > JS logic: a) On auto-join, ask server to join the channel and get channel infos. b) The info tells the channel is not detached, but JS code makes decision to detach it, and tells server the channel is now detached. c) From (a), server notifies on longpoll bus the state of channel, which is not detached. The web client thinks that the window state of the channel has been changed somewhere else, and the channel is now closed. d) From (b), server notifies on longpoll bus the state of channel, which is detached. The web client opens the thread window of this channel. > The flicker didn't occur before refactoring because the web client was only updating the model of channel when it receives the longpoll notification. > Server behaviour on 1st longpoll notification is necessary for cross-tab synchronization for channel window state. > New design implies that model and view should be synchronized, hence the issue now. > Solution: remove server-side thread window synchronization and replace with client-side synchronization. ---------------------- Hacks ---------------------- The module `im_livechat` now uses mail objects that are compatible with Message and Window objects: Modeling for messages: AbstractMessage / \ / \ LivechatMessage Message - AbstractMessage: message compatible with the thread widget. - LivechatMessage: message used by im_livechat. - Message: message used with the mail manager. Modeling for thread windows: AbstractThreadWindow / \ / \ LivechatWindow ThreadWindow - AbstractThreadWindow: behaviour share between all types of thread windows. - LivechatWindow: window used by im_livechat. - ThreadWindow: window used with mail_manager. The reason for these hacks are twofold: 1. Use the thread widget in the frontend and livechat external lib bundles. 2. Do not have a dependency with the mail manager in the frontend and external lib bundles.
2018-06-28[MERGE] forward port branch saas-11.3 up to 3cdcbce93cbChristophe Simonis
2018-06-27[MERGE] forward port branch saas-11.2 up to 12ddec3a767Christophe Simonis
2018-06-27[MERGE] forward port branch 11.0 up to 152519cd658Christophe Simonis
2018-06-22[FIX] *: Avoid BlockUI for some rpcAdrien Dieudonne
Before this commit, the point of sale displayed a loading message every 5 secondes if the barcode scanner was configured. This issue is due to the following commit: @1aacc96 After this commit,some calls may block the interface when they did not do it before. It concerns all rpc done with ajax.rpc and all done with a new session. We have now to explicitly set shadow property. opw-1860493
2018-05-29[IMP] web: use burger menu for tablet in vertical modeKinjal Mehta
Task #34853
2018-05-03[MERGE] forward port branch 11.0 up to c591e0de7d1Christophe Simonis
2018-05-03[FIX] web: inline views should share their fieldsNicolas Martinelli
This causes issues (already 3, and counting...) This reverts commit 27c9f838d35f36f6fe8d68068ed96c5c58d9d186. opw-1840984 opw-1841041 opw-1841000
2018-05-02[MERGE] forward port branch 11.0 up to 521414b1c10Christophe Simonis
2018-05-02[FIX] web: inline views should share their fieldsLucas Perais (lpe)
Have a One2Many The views of that o2m define two inline views: the list and the form in the list view, put a field that isn't in the form and used in a domain Try to add an item to the list The form pops up Fill in the data and save & close Before this commit: It crashed when evaluating the domain on a field using the field that is not in the form After this commit: Subviews share their fields in a special object on the parent record In our case, the form view checks in that shared resource if the fields it is supposed to initialize are there. Hence, this flow doesn't crash anymore OPW 1837511 closes #24350
2018-04-19[DOC] web: add documentation on notification systemGéry Debongnie
Also, fix a few errors in the js docstring
2018-04-19[IMP] web: convert notification popup in service and add buttons paramsChristophe Matthieu
this.call('web.Notification', 'notify', params) Display a notification at the appropriate location, and returns the reference id to the same widget. Note that this method does not wait for the appendTo method to complete. @param {Object} params @param {string} params.title notification title @param {string} params.message notification main message @param {string} params.type 'notification' or 'warning' @param {boolean} [params.sticky=false] if true, the notification will stay visible until the user clicks on it. @param {string} [params.className] className to add on the dom @param {function} [params.onClose] callback when the user click on the x or when the notification is auto close (no sticky) @param {Array<Object>} params.buttons @param {function} params.buttons[0].click callback on click @param {Boolean} [params.buttons[0].primary] display the button as primary @param {string} [params.buttons[0].text] button label @param {string} [params.buttons[0].icon] font-awsome className or image src @returns {Number} notification id this.call('web.Notification', 'close', notificationId)
2018-04-12[FIX] web: define XL size in config.deviceMartin Geubelle
In Less, the size_class XL is now defined and can be used in media-queries. It is also added in JS for the sake of consistency. This new size is needed for a fix in enterprise.
2018-04-12[FIX] web: define XL size in config.deviceMartin Geubelle
In Less, the size_class XL is now defined and can be used in media-queries. It is also added in JS for the sake of consistency. This new size is needed for a fix in enterprise.
2018-04-10[IMP] web: keyboard navigation in form viewVincent Schippefilt
The goal of this commit is to allow fast entry of the same model using the keyboard for navigating through the form once, by blocking the user from advancing in the form if there is a required field or once they went through the form once to get them to a primary action (button) This commit includes the following changes 1) Enable moving forward from field to field using the TAB key 2) Entering the one to many and many to many using the TAB key a. When entering it, set the focus on the "add new line" link or button b. When adding a new line, set the focus on the field visible editable field of the new line c. Discard adding a new line with ESC key d. If the user leaves the first field empty and uses TAB, we will cancel the adding of a new line and move to the next field of the form 3) When a field is required and not filled in, do not allow the user to move out of the field using the TAB key (the user is still allowed to use the mouse though), mark the field as invalid instead 4) After going though the form once, using the TAB key on the last field will move the focus to the first primary button of the page 5) When the focus is on a primary button (EDIT/SAVE), the user cannot move the focus forward using the TAB key. Hitting TAB again will display a tooltip telling to hit ENTER to activate the button. The mouse is still available to move the focus. 6) When the user saves, the focus is placed on the first primary button of the form renderer (like VALIDATE for a new invoice) 7) On dialogs, primary buttons should stop the users from moving out of them, and showing a popup if the user tries 8) When closing a dialog, the focus will be moved back to the widget that opened it. This commit does not include the following features 1) Navigation with the keyboard on a selection one to man 2) Navigate between tabs in a form using the keyboard 3) Cancelling the adding of a new line in a many to many using the ESC key do not set the focus correctly 4) Enhancing the focusses fields (like blue underline)
2018-03-23[IMP] web: add sessionStorage serviceAaron Bohy
This rev. adds the 'sessionStorage' service, allowing to write and read stuff in/from the sessionStorage (with a compatibility layer to handle the case where the sessionStorage can't be used, e.g. private browsing in Safari, like it is already done for the localStorage). This new service is necessary for the ActionManager to store the current action, so that it can be fully restored on F5 (this comes with the next commit).
2018-03-01[MERGE] forward port branch 11.0 up to c2e878e34c8Christophe Simonis
2018-02-22[FIX] web: return dialog in web.CrashManager functions Dennis Sluijk
This is more a architecture fix than a bug fix. With this commit, it is easier to modify the behavior of the dialog using the super function. like this: this._super.apply(this, arguments).opened(...) PR #23255
2018-02-12[FIX] mail,web: JS mail and services tracebacksAlexandre Kühn
Fix over this commit: https://github.com/odoo/odoo/commit/02ec09cb1c3e2d7bc7968f40c18f2208d7f3f498 In mobile, when discuss is installed, there is a traceback. This is a consequence on an issue with JS services, where some of them are not registered in the service provider. For instance, the webclient (the service provider) was instantiated before chat_manager (a service), so it was not aware of this service. To solve this issue, service providers now listen on newly registered services. Also improving deployment of JS services by not relying on topological sort.
2018-02-01[REF][IMP] *: mail js refactoringAaron Bohy
This commit improves the JS code of the mail module, which comes maily from the new coding guidelines and the addition of "JS services". JS services are important objects that do not fit well in the component tree, such as chat_manager or ajax. The benefits of JS services are improved readability of the code, reduced coupling, and more testable modules. In particular, discuss was hard to Summary of the changes: - ClientAction has been renamed into Discuss - Clear instantiation of chatManager - New coding guidelines in most mail modules - JS Services can interact with each other - Chat Manager and Window Manager are services - Window Manager renamed to Chat Window Manager - bus.bus is now encapsulated in Bus Service (a service) - The test infrastructure has been tweaked with JS Services - Chat Mixin has been removed A future improvement would be to translate some 'trigger' into 'trigger_up'.
2018-01-26[IMP] web,*: config: add XXS size to config.deviceAaron Bohy
In Less, the size_class XXS is defined and used in media queries. This rev. adds it in JS for sake of consistency. Code in addons comparing the size_class needed to be adapted due to the new XXS size_class. Moreover, we now use the helper 'config.device.isMobile' everywhere we should, instead of manually comparing the size_class. Finally, we changed the way the config.device has to be specified in the test environment. From now on, only the size_class should be set, and the isMobile flag is computed automatically.
2018-01-26[REF] web,*: move fvg processing from DataManager to ViewsGéry Debongnie
*: mail, web_diagram
2018-01-22[MERGE] forward port branch saas-11.1 up to fa1f2132e79Christophe Simonis
2018-01-22[MERGE] forward port branch 11.0 up to 950d9b23690Christophe Simonis
2018-01-16[REF] web: ActionManager: report actionsAaron Bohy
Adapt code to the ActionManager refactoring, and to the new coding guidelines. Also add some tests.
2018-01-16[FIX] web: config.debug and session.debug equivalenceAaron Bohy
Before this rev., config.debug was always a boolean, whereas it should also encode the special value 'assets', as done in session.
2018-01-15[FIX] web: disable {bin_size: true} on binary fieldsAlexandre Kühn
Revision on 41fe7f9d1113d026b226b136b4477aaaf9f1f638 This commit intended to reduce the network load when reading records with binary fields. This was made possible by enforcing the contextual key `bin_size` to be set for records with binary fields. However, it is causing some issues (see #22222, #22231) which are: - write with bin_size:true generates a traceback - read/search_read with bin_size:true breaks some images on some views (e.g. base.view_partner_form) Since the problems outweight the gain of these changes, we revert them.
2018-01-12[MERGE] forward port branch 11.0 up to 3b80a059ff4Christophe Simonis
2018-01-12[FIX] web: contexts on field widgets + enforce bin_size for binaryAlexandre Kühn
Field widgets now have a key 'context' that let them extend the context of the dataPoint (e.g. list). In particular, widgets on binary fields enforce the contextual item {bin_size: True}, so that the server gives the size of the binary field as its value, instead of its content. This change on binary fields reduces network load when accessing a view with binary fields.
2018-01-10[MERGE] forward port branch 11.0 up to ff0abd214c8Christophe Simonis