summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/chrome/action_manager.js
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-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'
2017-10-16[FIX] web: discarding a new record in a modal closes the modalKhoi Nguyen
Discarding a new record triggers the 'history_back' action. This makes sense if the record was discarded from a normal form view, but not so much when in a modal, where the expected behaviour is to close the dialog. This commit overrides the function in the action manager which handles the switch to the previous view. It checks whether a dialog window is open, in which case it simply closes it.
2017-09-29[FIX] web: discarding a new record in a modal closes the modalKhoi Nguyen
Discarding a new record triggers the 'history_back' action. This makes sense if the record was discarded from a normal form view, but not so much when in a modal, where the expected behaviour is to close the dialog. This commit overrides the function in the action manager which handles the switch to the previous view. It checks whether a dialog window is open, in which case it simply closes it.
2017-09-28[MERGE] forward port branch saas-16 up to 89df681b458Christophe Simonis
2017-09-27[FIX] *: correctly use `session`Martin Geubelle
Widget has no attribute `session` since the new views. One should either use `getSession()` or require `web.session` (both cases are correct).
2017-09-18[FIX] *: fix a bunch of incorrectly documented docstringXavier Morel
Fix a bunch of ill-documented/incomplete/incorrect method docs Without this, the automatic doc generation does not work.
2017-07-24[IMP] web, *: lazy load dialog xml templateqsm-odoo
* web_editor, web_planner, website The 'Dialog' class is used in both backend and frontend. Also, lots of actions can be done without the use of any modal. It thus makes sense to lazy load its related xml only when a first modal is opened. This change also allows to get rid of the "base_common.xml" file as the dialog template is the only remaining one in there and, in the future website update, it will allow to not load any static XML file on website page loadings.
2017-07-14[MERGE] forward port branch saas-16 up to 4ca3d9cadf9Christophe Simonis
2017-07-13[FIX] web: Discard from form view to form viewElkasitu
Clicking on the discard button in a form view whose previous view is another form view wouldn't do anything. This is fixed by making the view_manager trigger_up a history_back event and then the history_back callback will handle cases in which there is only one view and only one action, which used to be rejected
2017-07-12[ADD] web, *: add rainbowificationDharmraj Jhala
This commit introduces the 'rainbowification' feature to the web client (and to some affected addons). This feature is essentially a way to display a nice friendly message when some business event happens. For example, a encouraging message is displayed when the user clear her/his inbox, or when a salesman closes a deal. The mechanism currently only displays a 'rainbowman', but could be extended later to add other kind of animation. There are a few different ways to display a 'rainbowman': - any JS code can simply trigger_up an event ('show_effect') with some options: for example this.trigger_up('show_effect', { type: 'rainbow_man', fadeout: 'no', message: $done, click_close: false, }); - an action returned by the server can have an 'effect' key, with some options - the do_execute_action method accepts a 'effect' option. This is useful when one wants to specify a rainbow on an action button in a form view Joint work with: dbh <dbh@odoo.com>, ged <ged@odoo.com>
2017-06-01[MERGE] Forward-port saas-16 up to ba15df47cb25625cb0921cba554aa0879048c90aOlivier Dony
2017-05-24[FIX] web: ActionManager: protect set/get scrolltop methodsGéry Debongnie
Here is what could happen before this commit: open a record (let's say project.task) in form view. Then, on the sidebar (actions), choose Merge Selected Tasks), choose a task, and click on Merge. What happens next is a traceback. Here is a more precise description of what happened: - the formview dialog for the merge action closes, which triggers a reload for the main formview - the merge action returned an action description for an act_window - the action manager instantiated a new viewmanager and prepare the form view, which is an async operation (need to load some data to display the form) - the previous view manager (initial one) completes its reload, which makes it rerender the view, which triggers a DOM_updated event - the new view manager see this event, and tries to call getScrollTop on the current view controller, but there are no controller yet, it is not ready. We could argue that some of these events should not happen (for example, if we will open a new view manager action, why do we reload the current view manager?). But solving these issues is a more deep architectural problem (we probably will rewrite the actionmanager/view manager layer at some point). It could also be argued that in any case, the method getScrollTop should not crash (same for setScrollTop). Sadly, these methods are fragile, because some changes in the loading behaviour of a view may break them. So, in any case, protecting them against unexpected traceback is a worthwile investment.
2017-05-08[REM] odoo/report: remove deprecated stuffLaurent Smet
- RML Reports - Webkit Reports (most part already removed by 13b9982c6298021289707ed364e3c1d622a09f13) - LocalService in netsvc.py - rename attributes like rml_% to report_% - rename ir.actions.report.xml to ir.actions.report - allow rendering directly on an ir.actions.report by calling render method - remove 'controller' report_type - remove unused res.font stuff - remove print_report method in models.py (not used) - restore removed call to pdftotext process in test_reports