summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/chrome/action_manager.js
AgeCommit message (Collapse)Author
2021-01-20[FIX] web: Dialog widget should always call on_{attach|detach}_callbackPierre Paridans
Before this commit, the `on_attach_callback` and `on_detach_callback` callbacks are not called all the time on the `Dialog` widget when it's attached/detached to the DOM. Relying on those callbacks could result in unpredictable behaviours. To be more precise, the `on_attach_callback` isn't executed on a regular Dialog#open() call. But Dialog spawned by the ActionManager will execute it. This difference prevents from properly binding those callbacks later on through an extend or include of the Dialog widget as we have no way to know if they have already been called or not (e.g. which can result in calling them twice). This commit normalize this situation by ensuring that the `on_attach_callback` and `on_detach_callback` callbacks are properly called by the Dialog widget and allows any extension of this widget to rely on them. Therefore the ActionManager is adapted accordingly. opw-2438534 closes odoo/odoo#64780 Related: odoo/enterprise#15849 Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2020-07-30[FIX] web: Close dialog when clicking button with close attributeLucas Lefèvre
In a dialog, a button with `close="1"` should close the dialog when clicked. It currently only works if the dialog is a subview. closes odoo/odoo#55200 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Co-authored-by: fleodoo <fle@odoo.com> Co-authored-by: aab-odoo <aab@odoo.com>
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-06-12[FIX] web: force webclient to finalize its loadingLucas Perais (lpe)
When the web client is completely ready, it triggers an event "web_client_ready" on the bus Some Mail OWL components rely on that mechanism to be mounted i.e. DialogManager and ChatWindowManager When eveluating the action to display at startup, the webclient mechanism implies that we push the location hash each time a relevant data is available e.g. menu_id etc... Now, before this commit, since the hashchange handler is bound before that evaluation it is actually triggered each time the JQuery bbq pushed a url state (this is in the API) doc: http://benalman.com/code/projects/jquery-bbq/docs/files/jquery-ba-bbq-js.html#jQuery.bbq.pushState This undercuts the initial loading promise chain to finish and the event "web_client_ready" was never triggered preventing everything that relied on it to be mounted After this commit, the webclient is artificially finalized, with the help of a new custom event "webclient_started". So the event web_client_ready is triggered, signalling to everyone it is in the dom and usable A lot of bug persist though: the start() of webClient sometimes returns a rejected promise It is worth noting that the hashchange mechanism is largely outdated and will change in a more reliable way in the near future with the conversion of the webClient to OWL the drop of JQuery BBQ and the direct reliance on window.history.pushState doc: https://developer.mozilla.org/en-US/docs/Web/API/History/pushState#:~:text=The%20state%20object%20is%20a,the%20history%20entry's%20state%20object. and on the window's "popstate" event doc: https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event This commit must be applied on the enterprise webclient too closes odoo/odoo#52892 Related: odoo/enterprise#11114 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2020-03-13[REF] web: Adapt views/actions to new control panelJulien Mougenot
Some web actions/controllers/viewsl have been adapted to properly instantiate the newly refactored control panel and update it accordingly. We needed to adapt the starting mechanism of actions and controllers to ensure that the control panel instantiation did not delay the loading of any widget. Part of task 2196029 Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
2019-12-11[FIX] web: fix click_all testVincent Schippefilt
Before this commit, after the introduction of OWL, for some reason, maybe because the session is ready earlier or later, the webclient is opening the first app sightly earlier than before, making it too early. The click_all failed actually because, in the initialization of the webclient, it does a read on read user, protected by a drop_previous it tries to start the first applictaion, when this happens, the hash changes ==> because the hash changes, it tries to open an application, with is also protected by the same drop previous, this discarding the result of the read and preventing the then callbacks of the read to happen. After this commit, we are declaring that the client is ready after the actual load of an application. closes odoo/odoo#41695 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-10-31[IMP] web: allow custom state in action mixinDamien Bouvy
Sometimes, it might be useful for an action (e.g. a client action, although this may be used by standard views as well) to include custom values in its state. Since the state of a 'fullscreen' action is pushed in the URL, this means that it is possible for the action to resume its state properly upon refresh of the page (before this commit, only some standard information were pushed to the state - action_id, menu_id, etc. for window actions and action's name, active_id, active_ids for client actions). By implementing the `getState` method, an extension of the action mixin can thus push any state it wishes to the URL. closes odoo/odoo#39529 Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
2019-10-14[FIX] web: warn is show when a client action is a functionRomeo Fragomeli
Before this commit, if we use some client action like: reload, logout, ... in the console a warning is show, because the action are function and not AbstractAction. After this commit, if the client action is not an function and not a AbstractAction the warning is show. X-original-commit: 122b76594aeb2c5d923d13c040c2da2048133aac
2019-08-07[IMP] *: fix typos in commentsmreficent
closes odoo/odoo#35404 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-09[FIX] web: don't close dialog on doAction with target 'new'Aaron Bohy
Rev. ee44d23 fixed a usability issue: when a doAction is performed from a dialog, it automatically closes the dialog (as the action is rendered in the background, behind the dialog). However, it also closes dialogs when the action has target='new', i.e. when it also opens in a dialog, which is not strictly necessary in this case. This is problematic in mobile for the product configurator widget: in the sale.order form view, the order_line field is displayed as a kanban, and in its form view, the product_(template_)id field has widget product_configurator. When a value is set, it performs a doAction (target="new") to configure the product. The widget listens to the dialog's 'closed' event to update itself. However, with what is done in ee44d23, the x2many form dialog is closed by the DoAction, so the flow doesn't work. This rev. reverts the attempt done in ee44d23, and does something a bit more brutal: as soon as an action is pushed in target 'current' (in the main part of the interface), all dialogs are automatically closed. closes odoo/odoo#34678 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
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-06-05[IMP] web, web_tour, website, point_of_sale: adapt code to new debugRomain Derie
As now the debug state is stored in session, the JS framework code and some templates needed some changes. First, the debug state is retrieved from session and not the URL anymore. Second, the debug state does not need to be forwarded as it is now persistent. task-1934445 Comes with https://github.com/odoo/enterprise/pull/4281 Closes #33213
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-01-09[MERGE] forward port branch 12.0 up to 3e4138deaa2Christophe Simonis
closes odoo/odoo#30045
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-11-28[FIX] web: action manager fullscreen toggleLucas Perais (lpe)
From a standard view with the main menu (what is called a target=current action) open a target=fullscreen action Then, go back to the first action, with the breadcrumbs for example Before this commit, the original view was displayed fullscreen, which impaired business navigation because the main menu was not there anymore After this commit, the original view has the main menu OPW 1906373 closes odoo/odoo#29096
2018-10-23[REF] web: small refactoring pass on some web componentsAaron Bohy
(mainly views and ActionManager) - add missing docstrings - fix typos - correctly order functions and imports - put functions in correct sections - stop using 'event' as argument of handlers - don't call handlers directly - remove trailing spaces/tabs - move module created in stable version to its own file - follow js guidelines in general closes odoo/odoo#28024
2018-08-31[FIX] web: call on_close handler from history_backAlexandre Kühn
Revision on https://github.com/odoo/odoo/commit/3210f108272be89f1a7b01f4e1816b7f04ae0a3b Before this commit, when doing an action that opens a dialog (with `target: 'new'`), then triggering 'history_back', the `on_close` handler of the action was never called. This was not the correct behaviour, because the dialog closes without the `silent` option set. Indeed, when this option is not set, it should always call the `on_close` handler. The bug comes from closing the dialog without any options, and this case was not handled correctly in the commit above. This commit fixes the problem by ensuring that the `on_close` handler is called even when closing the dialog without any option.
2018-07-16[IMP] web: provide infos for close actionAlexandre Kühn
With this commit, when we perform a close action, we can provide infos to the `on_close` handler, so that it can handle different cases that caused the close action.
2018-07-06[REF] *: rename web.pyeval into web.py_utilsGéry Debongnie
The pyeval name is quite confusing, given that there is already an eval and an evaluate function in py.js, and that the web.pyeval exports two evaluate functions. Since this file is more about odoo specific customization to py.js, it is renamed in py_utils to better express its intended use.
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-21[FIX] web: actions target=new should transmit their on_closeLucas Perais (lpe)
Have an action that opens a dialog, with a specific callback to execute when the dialog closes In the dialog, have a button linked to an action that opens another dialog in target = new Close this 2nd dialog Before this commit, the callback was not executed After this commit the callback is executed OPW 1853136 closes #25180
2018-06-19[FIX] web: enable button at end of actionNicolas Martinelli
When clicking on an action button, the following steps are performed: 1. Buttons are disabled 2. The button call is performed 3. At the end of the call, the buttons are enabled 4. Extra RPC are performed (`read`, `name_get`) 5. When the RPC calls are finished, the form is reloaded In the case of a validation of a SO, it means that the 'Confirm' button is enabled at step 3, but hidden at step 5. On a slow network (or an overloaded server), it means that the user has enough time (step 4) to click again on the 'Confirm' button and trigger the action more than once. The root cause is that we don't retrieve the promise of the `reload` mechanism (defined in `_callButtonAction`) when executing `on_close` (triggered after the button call). We return a promise which is resolved and enable the buttons too early. We make sure to retrieve the promise of the `reload` and return it, so that the promise of `saveAndExecuteAction` (defined in `_onButtonClicked`) is correctly linked to it. This way, `_enableButtons` is called when the reload is performed. Co-authored-by: Aaron Bohy <aab@odoo.com> (well, actually he did most of it) opw-1859027
2018-06-11[FIX] web: correct 'popup blocked' error message.Arnold Moyaux
task-30450
2018-05-29[MERGE] forward port branch saas-11.3 up to 37eed7c509fChristophe Simonis
2018-05-24[IMP] web: improve act_urlRémi Rahir
By default, Chrome browser will block pop-up windows which will block all actions from type act_url with a different target than 'self' (i.e. '_blank'). This commit adds a check when such an action is called and sends a warning in the web client when it fails to open. This mimics the behaviour already present for the report actions.
2018-05-08[FIX] web: ActionManager: store evaluated contextAaron Bohy
... in session_storage. The current action is stored in the session_storage (stringified), so that it can always be restored on F5 (useful for dynamic actions). Before this rev., it was stored with it's 'raw' context, i.e. before its evaluation. However, when this context is an instance of a CompoundContext, it is meaningless once restored. So this rev. ensures that the action is stored with its evaluated context.
2018-04-16[MERGE] forward port branch saas-11.2 up to 90f8f17fb4fChristophe Simonis
2018-04-13[FIX] web: always update breadcrumb on change titleAlexandre Kühn
Revision on https://github.com/odoo/odoo/commit/32b8cec5361174c92c45a4975d4e02f1fb448aa2 Before this commit, when we switch channels in the Discuss app, the breadcrumb was visually not updated: it keeps the name of the first opened channel. With this commit, the breadcrumb is updated on each change of channel, so that it displays the name of the currently opened channel. Technical details: This is due to a change of logic of updating the GUI of the breadcrumb: before the refactoring above, discuss had to pass the content of the breadcrumb to the control panel, in order to update the breadcrumb visually. After the refactoring, the action manager should warn the control panel to update the breadcrumb on any change of the title. This is already the case for `ir.actions.act_window`, but not for all types of client actions.
2018-04-12[FIX] web: prevent race condition with client actionsGéry Debongnie
Here is the issue that initiated this work: the bank reconciliation tour sometimes failed in community. The reason was that the discuss client action seemed to be loaded after the tour started, and interfered with the second step of the tour. What happened exactly was the following: - web client is loaded - initial action is starting (but not complete) (this is discuss) - tour manager is loaded and starts the reconciliation tour - the reconciliation tour changes the url to trigger an hash change - the web client calls loadState on the action manager - the action manager perform a doAction with the tour url - the discuss client action is now ready, and replace the reconciliation action - the tour is broken. The underlying cause is really a generic problem: the action manager does not add the client action starting process in its 'dropprevious' concurrency primitive. This is probably not really an issue for the act_window actions, since they have custom loading code that make sure the loading process is put in the drop previous, but it is definitely a problem for all client actions. The solution is quite simple, and should also protect the act window renderers: put the action controller in the drop previous
2018-04-12[FIX] web: prevent race condition with client actionsGéry Debongnie
Here is the issue that initiated this work: the bank reconciliation tour sometimes failed in community. The reason was that the discuss client action seemed to be loaded after the tour started, and interfered with the second step of the tour. What happened exactly was the following: - web client is loaded - initial action is starting (but not complete) (this is discuss) - tour manager is loaded and starts the reconciliation tour - the reconciliation tour changes the url to trigger an hash change - the web client calls loadState on the action manager - the action manager perform a doAction with the tour url - the discuss client action is now ready, and replace the reconciliation action - the tour is broken. The underlying cause is really a generic problem: the action manager does not add the client action starting process in its 'dropprevious' concurrency primitive. This is probably not really an issue for the act_window actions, since they have custom loading code that make sure the loading process is put in the drop previous, but it is definitely a problem for all client actions. The solution is quite simple, and should also protect the act window renderers: put the action controller in the drop previous
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-30[FIX] web: ActionManager: call 'on_attach_callback'Aaron Bohy
for actions in target='new'. Before this rev., it was only called on the dialog, but not on the controller rendered inside it.
2018-03-23[IMP] web: ActionManager: load window actions without idAaron Bohy
Actions can be loaded from the state of the url (e.g. when pressing F5). For window actions, it was working properly if the action id or a record id (i.e. for form views) was given. In other words, states like 'model=res.partner&view_type=kanban' couldn't be loaded. This can be explained by the fact that without an action id, the context and domain of the action couldn't be obtained. This rev. solves this problem by storing the current action into the sessionStorage, so that important information like context, domain and name can be retrieved if this action has to be restored (i.e. if the user refreshes the page).
2018-03-21[MERGE] forward port branch saas-11.2 up to 500e3f49705Christophe Simonis
2018-03-16[FIX] web: ActionManager: concurrent window actionsAaron Bohy
This rev. strengthens the handling of concurrent actions of type 'ir.actions.act_window' in the ActionManager. In particular, the two following cases are now handled: - execute an action A, its 'load_views' RPC takes a while, during that time, execute an action B: A can be dropped, meaning that it doesn't need to fetch its data, and thus it should not be appended to the DOM (nor appear in the breadcrumbs) ; - execute an action A, its 'read' or 'search_read' RPC takes a while, during that time, execute an action B: A can be dropped and should not be appended to the DOM (nor appear in the breadcrumbs).
2018-03-14[FIX] web: don't push state of loaded client actionsAaron Bohy
Loaded actions (i.e. executed from url state, e.g. after an F5) should not push their state back to the url. This was working fine of act_window actions, but not for client actions, and this was causing an issue in Studio as the same mechanism is used to prevent the main Studio client action from pushing its state into the url (to keep the state of the edited action in the url instead).
2018-03-10[IMP] web: restore scroll positionAaron Bohy
This rev. improves the way the scroll position is restored when coming back to a view (e.g. open a kanban view, scroll, click on a record to open it in a form view, go back to kanban using the breadcrumbs): - generalize the scroll position handling from web_enterprise to web to make it available in the community webclient as well - also restore left scroll position, not only top (especially useful for grouped Kanban views with a lot of columns) - handle the case where the scrolling area is a sub element of the view (e.g. the grouped Kanban view in mobile). Task 34037 Co-authored-by: Mohammed Shekha <msh@openerp.com> Co-authored-by: Ankit Sathvara <asa@odoo.com>
2018-03-09[MERGE] forward port branch saas-11.2 up to 42659dc70c2Christophe Simonis
2018-03-09[FIX] web: ActionManager: push state of loaded actionsAaron Bohy
Actions loaded from the url are flagged with 'pushState: false', to prevent them from pushing their state back to the url, thus producing an infinite loop. However, if the state of a loaded action changes in the future (e.g. load an action in kanban view, then switch to a form view), this state should be pushed to update the url. Before this rev., this wasn't the case.
2018-03-08[REF] web,*: introduce the concept of AbstractActionGéry Debongnie
Before this commit, a client action was simply a subclass of Widget. This is quite simple, but not really enough for the ActionManager. The ActionManager needs to handle client actions in a different way that view actions. Sometimes, it needs to check if a method exists before calling it. With this commit, we introduce a new abstraction: the AbstractAction class, which defines a common API for all actions managed by the web client. Note that the API proposed in this commit is just the beginning. We will introduce other methods in the future, to manage the focus, or the scroll position, for example.
2018-02-26[FIX] web: doAction always resolved with the actionAlexandre Kühn
Before this commit, doAction returns a deferred that is resolved when the action is performed (the exact moment depends of the type of the action). However, the deferred was not resolved with the action. This is misleading, hence a traceback in the web_client when clicking on 'Run JS Tests' in debug mode (enterprise): after doAction, the web_client should hide the home_menu depending on the type of the action. With this commit, any doAction returns a deferred that is resolved with the performed action.
2018-02-15[FIX] web: ActionManager: handle false actionsNikunj Ladava
Server actions return an action to execute, or false. When they return false, an 'ir.actions.act_window_close' must be executed, such that the current dialog closes (if any) and mostly, the 'on_close' handler is executed, which ensures for example that the current view is reloaded. The case where server actions return false has been broken by rev. 32b8cec53. It produced tracebacks in several models, when clicking on some actions in the 'Action' dropdown. For instance, in lunch, go to Configuration > Products, open one in a form view, and click on 'Lunch: Archive/Restore products' in the Action dropdown.
2018-02-15[FIX] web: factorize some `doAction` preprocessingMartin Geubelle
This preprocessing also needs to be done in Studio so it's factorized in a separate function.
2018-02-01[IMP] mail: redirect on mail activityArnold Moyaux
Allow to redirect on a form view when the user click on a html tag a with data-oe-model and data-oe-id specified. In order to avoid code duplication the do_action already existing in mail_thread is moved in the action_manager and mail_thread and mail_activity use a trigger_up in order to call it.
2018-01-16[REF] web,*: ActionManager/ViewManager refactoringAaron Bohy
This rev. is the first part (out of 3) of the refactoring of the ActionManager and ViewManager layer of the webclient. The main changes are: - there is no ViewManager anymore, its work is now handled by the ActionManager itself, but isolated in a specific file ; this eases a lot of things, as the breadcrumbs handling for example. - the ActionManager code is converted to the new coding principles and guidelines ; mainly, children widgets communicate with it by triggering events up, and not by function calls anymore. - the ActionManager layer is now testable, and a lot of tests have already been written. - the code in other addons has been adapted consequently. What's coming next: - introduce the 'AbstractAction' Widget, and make client actions and view controllers inherit from it ; this widget will implement a common API that could be used uniformly by the ActionManager (e.g. restore(), canBeLeft(), renderButtons(), getTitle()...). - move the ControlPanel handling from the ActionManager to the AbstractAction.
2018-01-02[MERGE] forward port branch saas-16 up to 0af13af5de4Christophe Simonis
2018-01-02[MERGE] forward port branch saas-15 up to ddd293065ecChristophe Simonis
2017-12-05[FIX] web: debug_manager: change view_type to form in urlAdrien Dieudonne
Before this commit, there were an error when you tried to change the view_type directly from the url in debug mode. The controller of the view wasn't defined and a crash happened when we tried to render the DebugManager.View. To fix this, we now wait for the 'switch_mode' which sets the controller to the active view. 'do_load_state' is now chained to 'switch_mode'