summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
AgeCommit message (Collapse)Author
2019-07-22[IMP] web: do not set focus on form when lastActivatedFieldIndex is not setMohammed Shekha
When opening a dialog using mouse and closing it, form_dialog_discarded is triggered, which tries to set focus on form while lastActivatedFieldIndex is -1, as dialog is opened using mouse directly do not set focus back to form widget if lastActivatedFieldIndex is -1 task-2031706 closes odoo/odoo#34684 Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
2019-07-11[FIX] web: batch read of m2m in o2m after onchangeAaron Bohy
Let's assume a one2many field (editable list) in a form view with a many2many (e.g. many2many_tags), and an onchange on the one2many such that, when a row is added to the relation, the server returns update commands for (a subset of) the records being already in the relation. For thoses updated records, the many2many field needs to be read (the onchange only returns the ids in the relation). Before this rev., the many2many field was read independently for each record in the one2many. This could cause a performance issue on large relations. For instance, this was the case on account.invoice records with a lot of lines. This commit must be forwardported up to 12.2, not further. Issue 2027356 closes odoo/odoo#34771 Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
2019-03-29[MERGE] forward port branch saas-11.3 up to ec29b4d3648Christophe Simonis
2019-03-25[FIX] web: modal in modal => no block mobileNicolas Lempereur
On a form view: - we open a modal form view - in this modal we open a modal form view - we close that second modal => the modal is closed and the first one is still opened, but on mobile we can't scroll to above or below the modal. This is because bootstrap remove .modal-open class on body when we close the second modal, but this class is necessary to scroll (this is not much an issue on desktop since scroll is often not necessary). We already had a fix that was weakened in 02a063fd73. With this changeset, we keep .modal-open as long as a modal is opened. Without the change, added test failed with: 10. Modal is said opened (expected: true, result: false) opw-1948423 closes #32106 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-03-13[MERGE] forward port branch 11.0 up to c23d1186e7bChristophe Simonis
2019-03-13[FIX] web: hide handle on readonly x2mMartin Geubelle
The widget handle was displayed on x2m fields in form views, even when the field was readonly, which makes no sense. It is now correctly hidden. Fixes #30580 opw-1937833 closes odoo/odoo#31743 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-03-14[MERGE] forward port branch saas-11.3 up to f5ab04ce509Christophe Simonis
2019-01-15[MERGE] forward port branch 11.0 up to 4f2f2995346Christophe Simonis
2019-01-11[FIX] web: one2many list: quickly switch between pagesAaron Bohy
Before this rev., a crash might occur when the user quickly switched twice between pages (e.g. go to page 2, then page 3) on a slow network. In the given example, when data of page 2 returned, the list was re-rendered. Unfortunately, the offset of that list' datapoint was already changed due to the switch to page 3, meaning that the view tried to render a page that wasn't loaded yet, leading to a crash if there were modifiers to evaluate, or to empty records being displayed. This rev. ensures that the view is rendered with the data of the page it expects. closes odoo/odoo#30150
2019-01-11[FIX] web: reset offset in the search more view dialogNans Lefebvre
Start on the modal obtained by a "search more". The offset is never reset. So suppose you are on page 2, looking at record 81-160. Do a research that gives less than 80 records. The result of the search is nothing, since is has been done with a 80 offset. It should be reset to 0 when we do a new search. opw 1920826 closes odoo/odoo#30109
2019-01-08[MERGE] forward port branch 11.0 up to c07b7200b26Christophe Simonis
2019-01-04[FIX] web: X2Many read propagates field contextNicolas Lempereur
Most operations on X2Many widget possibly propagates a field context (name_create, name_search, ...) but the original read or read on an onchange does not. With this changeset, the field context is also used in these instances. The assertions added in the added test failed with: expected: ["world"], result: [undefined] expected: ["world","world"], result: [undefined,undefined] fixes #29203 opw-1914466 closes #29866
2019-01-02[FIX] web: adapt forward-ported testChristophe Simonis
2019-01-02[MERGE] forward port branch 11.0 up to d82c0d133edChristophe Simonis
2018-12-19[FIX] web: read records up to list limitlen-odoo
Fine-tuning of commit e7fab234201e357da52c3576ad2e8fc9ceee9359 In a one2many with more than one page with a limit of k records, add a line l. It increments the list limit to k+1. Remove a line above (of index <= k). It will try to load a line l' to replace it, that it will find on page 2. However when deciding if it should read missing fields on that record, it will scan at most u records, skipping virtual ids. Here u is the min between the current number of lines and the list limit without the temporary increase due to the added record. Since there are at least two pages, u = k. However since l is in the list at index k, then l' won't be read, and since it was on page 2 its data hasn't been loaded. Therefore the js would traceback when trying to evaluate it. opw 1913361 closes odoo/odoo#29338
2018-12-18[FIX] web: x2m in x2m with different fields in different viewsMartin Geubelle
Use case: a x2m (ex: attribute values) displayed in a x2m (ex: attributes on product) using different fields in different views (ex: tags in product form view and list in product attribute form view). When opening the x2m record (in a wizard) then going back on the form view, the tags are empty because the `display_name` value has been lost when fetching x2m for the second time. In this case, the list `fieldsInfo` needs to be updated with the existing (default for tags) one so all the fields will be correctly loaded. Task 1916891 closes odoo/odoo#29598
2018-12-04[MERGE] forward port branch 11.0 up to 2156af480fdChristophe Simonis
2018-11-30[FIX] web: prevent crash in some cases (o2m)Géry Debongnie
Recent works in the orm (see [1] for example) changed the behaviour of the server in the case of onchanges: it tries to optimize Odoo by sending a minimal diff to the web client in onchanges. Concretely, this means that the web client receives commands 4 (link to) instead of command 1 (update + record data). It also sends a minimal diff in that case. This is a big issue for the web client, because it relied on the knowledge of the data from the command 1 to be able to evaluate some modifiers. The good news is that we can mitigate the issue in one case: we do not actually need to evaluate the modifiers in the case of a command 4 (comming from the server), because we can assume that the record is valid. So, we simply bypass the check in that case. Note that this should fix most of the problem, but a deeper problem still remains: a crash can still happen when an onchange modifies a record in a one2many (but in a different page), and we also have a modifier which needs to be evaluated. opw: #1904514 [1] https://github.com/odoo/odoo/pull/29086 closes odoo/odoo#29172 closes odoo/odoo#29086
2018-11-28[MERGE] forward port branch 11.0 up to bb6f6c57f97Christophe Simonis
2018-11-28[FIX] web: context orderedBy not propagated to x2mLucas Perais (lpe)
Have: - Model A with a x2m to model B - Object A with multiple objects B in x2m (that will be sorted) - On the list view of model A, click on a column to sort by a field - this field shall not exist in B - open a record A (towards form view) Before this commit, the sorting of the x2m crashed, because the key orderedBy was propagated Due to commit e713ed2a69af9fe97fbe2d54843adc8f1ce689aa After this commit, it doesn't crash OPW 1913133 closes odoo/odoo#29094
2018-11-22[MERGE] forward port branch 11.0 up to 263b388c504Christophe Simonis
2018-11-19[FIX] web: m2o+o2m in o2m onchange no lose dataNicolas Lempereur
Steps: - open a modal form view from tree view first line and make a change - open a modal from the second line and make a change - open the second line back: the change were lost In a given number of conditions (a many2one inside the form view, there is a one2many in the form view not inside the tree view, ....) this happened because: - when we save the first line, we get onchange data for the second one - this onchange data can't be applied before second line is loaded, but it is saved so it can be applied if second line is ever opened - when the second line is opened the saved change is applied => OK - when the second line is opened a second time the saved change is applied again, possibly overwriting posterious change => BAD With this changeset, when the record with unapplied onchange is loaded for the first time, the unapplied onchange is applied only once. Added test without the change failed with: - only 1 turtle for second partner (result: 0 not 1) - second partner turtle is Michelangelo (result: "" not "Michelangelo") opw-1846820 closes #28644
2018-11-26[FIX] web: list default_sort with multiple fieldsLucas Perais (lpe)
Define a x2m tree view with a default_sort including more than 1 field to order the list against Before this commit, the second field was never used After this commit, it is used OPW 1909785 closes odoo/odoo#28840
2019-02-27[FIX] web: avoid crash when clicking on colored m2m in listMartin Geubelle
With the BS4 update, a traceback occured when clicking on a m2m tag using colors in a list view. When using colors on m2m tags, the badge was wrapped inside a `dropdown-toggle`. However, there is no `dropdown-menu` by default (it is only rendered in FormFieldMany2ManyTags when clicking on the `.dropdown-toggle`, hence the traceback. The `dropdown-toggle` class is now only set if necessary. Task 1925313 closes odoo/odoo#31445
2019-02-06[FIX] web: only call name_get when necessaryAaron Bohy
For many2one fields, 'default_get' only returns the id, whereas 'onchange' (like 'read') returns an array with id and display_name. Before this rev., when creating a new record, we always called 'name_get' for all many2ones, whether or not their value was obtained by 'default_get' or 'onchange', i.e. even if their display_name was already known. It may just look like unnecessary RPCs, but those RPCs could actually cause a crash when the user has access to the main model (and thus can access the display_name of the many2one thanks to related sudo), but doesn't have access to the many2one comodel. closes odoo/odoo#30892
2019-01-16[MERGE] forward port branch saas-11.3 up to 83cc046e9a9Christophe Simonis
2019-01-08[MERGE] forward port branch saas-11.3 up to 2d824a5b7adChristophe Simonis
2019-01-04[MERGE] forward port branch saas-11.3 up to 27a084eb814Christophe Simonis
2018-12-18[FIX] web: call _applyX2ManyChange with the correct viewtypeNans Lefebvre
Have a one2many display records in a kanban subview, which opens a form view when edited. Edit a field displayed only on the form view. A call to _applyX2ManyChange is done without giving it the viewtype argument, therefore the fieldinfo is taken from the wrong view, traceback ensues. opw 1914163 closes odoo/odoo#29607
2018-11-30[FIX] web: prevent crash in some cases (o2m)Géry Debongnie
Recent works in the orm (see [1] for example) changed the behaviour of the server in the case of onchanges: it tries to optimize Odoo by sending a minimal diff to the web client in onchanges. Concretely, this means that the web client receives commands 4 (link to) instead of command 1 (update + record data). It also sends a minimal diff in that case. This is a big issue for the web client, because it relied on the knowledge of the data from the command 1 to be able to evaluate some modifiers. The good news is that we can mitigate the issue in one case: we do not actually need to evaluate the modifiers in the case of a command 4 (comming from the server), because we can assume that the record is valid. So, we simply bypass the check in that case. Note that this should fix most of the problem, but a deeper problem still remains: a crash can still happen when an onchange modifies a record in a one2many (but in a different page), and we also have a modifier which needs to be evaluated. opw: #1904514 [1] https://github.com/odoo/odoo/pull/29086 closes odoo/odoo#29172
2018-11-29[MERGE] forward port branch saas-11.3 up to c0eef427111Christophe Simonis
2018-10-31[MERGE] forward port branch 11.0 up to a587325ca7aChristophe Simonis
2018-10-31[FIX] web: reload many2one data if the context has changedlen-odoo
When a view is loaded, it checks which fields it has to load. In the case of a many2one, it could be the case that a context key is present in one view and not in the other; if it happens, we should reload the data, as a name_get result could vary. opw 1891295 closes odoo/odoo#28298
2018-10-30[FIX] web: consider correct viewtype when loading dataRémi Rahir
Before this commit, when loading the data and calling the prostprocess, the viewType was not correctly passed which could lead to broken behaviour. For example, if one was to load a record from a list view embedded in a form view, the viewtype passed was the list which prevented to load the data from the form view. OPW 1891295 closes odoo/odoo#28279
2018-10-16[MERGE] forward port branch 11.0 up to b29b545fe84Christophe Simonis
2018-10-12[FIX] web: prevent URL click from opening a recordSébastien Theys
If we click on a link, we only want to open the URL, and not the record when the button is on a list. PR: #27230
2018-10-09[FIX]web: do not crash when dismissing a modal with escapeMohammed Shekha
stopPropagation of navigation_move event for where direction=cancel, currently if navigation_move event throws error when user press escape in dialog where dialog is opened from editable list record Scenario: Install website_sale -> Open Product form(variant enable) -> open variant tab -> open Attribute m2o form popup and press Escape on dialog Result: Error Expected: It should close dialog and keep editable list view record open, btw m2o field should also be focused when dialog is closed but that's another issue, will be fixed in another ongoing task Related to Issue: #1873919 Co-authored-by: Vincent Schippefilt <vsc@odoo.com> Co-authored-by: Mohammed Shekha <msh@odoo.com>
2018-11-22[MERGE] forward port branch saas-11.3 up to b09f624f207Christophe Simonis
2018-11-09[FIX] web: extend the fieldsInfo of a view with the origin view to evaluate ↵Aaron Bohy
extra fields Suppose you are editing a SO to add a new line. Depending on the configuration, a sale order line wizard may open (e.g. if packages are activated). This wizard is a form view, opened from the tree view of the sale order lines. We have commit 8e5156938a9c87b80512bff9ecd025891406e624 that adds extra fields from the originating view. (However it doesn't work if the other view is inlined, so we modify this part to add the extra field even in this case.) Then we need the field info from the origin view in the target view; we do so by extending the former with the content of the latter. opw 1904337 closes odoo/odoo#28441
2018-11-06[MERGE] forward port branch saas-11.4 up to dc35de9d30bChristophe Simonis
2018-11-05[FIX] web: re-evaluate column_invisible after onchangeMohammed Shekha
Let's assume a form view with field A and B (a one2many list), with a column with attrs column_invisible depending on A. If the user sets A manually, everything works fine (the column is hidden/shown directly). However, if A is updated by an onchange (e.g. depending on the number of rows in B), it doesn't. This rev. fixes that issue. Related to Issue: 1851451 Co-authored-by: Priyanka Kaakdiya <pka@odoo.com>
2018-10-31[MERGE] forward port branch saas-11.3 up to 21eb31d8047Christophe Simonis
2018-11-02[MERGE] forward port branch saas-11.4 up to f6ca72b3ce9Christophe Simonis
2018-10-22[MERGE] forward port branch saas-11.4 up to 3c108977c1eChristophe Simonis
2018-10-17[MERGE] forward port branch saas-11.3 up to 0de06a41326Christophe Simonis
2018-10-11[FIX] web: close m2o (in o2m) dialog with ESCAPEAaron Bohy
Let's assume a one2many editable list containing a many2one field (e.g. in a sales order, the product_id m2o in order_line o2m), and the scenario where the user clicks on 'Create and Edit' in the o2m, and then presses ESCAPE in the opened dialog. Before this rev., it crashed because the 'navigation_move' (cancel) event wasn't stop propagated by the form renderer (the one of the dialog), and thus bubbled up to the list editable renderer, which asked its basic model to discard a record it didn't know. Note: same fix as in 8445baa (done in saas-11.3), but with a simpler test. Task 1878254
2018-10-12[FIX] web: stabilize sequence for new records on last pageSébastien Theys
Before this commit, the compute sequence was relying on the fact the ID was used as a secondary order key to get the right result. This is necessary when adding items between pages because we don't resequence the following elements. However this was not necessary when adding new elements on the last page since there are no following elements to resesquence in that case. PR: #27639
2018-09-25[FIX] web: focus 1st control in editable list on ESCVincent Schippefilt
Before this commit, when we click on the 1st control in an editable list (usually 'Add an item') then press ESCAPE, the focus was not on the 1st control. The intended behaviour is to have the focus on the 1st control, so that we may navigate left/right between controls solely with the keyboard. With this commit, when a cancel keyboard navigation event is triggered in an editable list, it auto-sets the focus on the first control. Co-authored-by: Alexandre Kühn <aku@odoo.com>
2018-09-25[FIX] web: improve automatic creation of new lines in x2many in formsVincent Schippefilt
This commit fixes a few issues with the previous implementation of the automatic addition of new lines in x2many inside forms 1. Before this commit, when there is a change of mode in a formview `edit` -> `readonly` -> `edit`, there may be some cases that mistakenly and automatically opens a modal. This case occurs in a form view with a x2many field whose 1st inner focusable element opens a modal (e.g. "Add an item"). In `edit` mode: 1. Open this modal from the x2many 2. Close the modal 3. Change mode to `readonly` 4. Change mode to `edit` > the same modal is automatically open. This is due to the tracking of the last activated field that persists after a change of mode. Since the last activated field in the 1st `edit` is the x2many, it is granted the focus at the beginning of the 2nd `edit`, which automatically opens the modal. This commit fixes the issue by resetting the tracking of the last activated field when there is a change of mode. As a result, at the beginning of the 2nd `edit`, the focus should always be on the 1st field. 2. Before this commit, if the focus was moved out of the form (to a modal for instance) then back, the form would re-activate the last field, which is the x2many and would re-add a new line. This behavior is not correct and now going back from a modal to a form does not add a new line. Co-authored-by: Alexandre Kühn <aku@odoo.com>
2018-09-25[IMP] web: x2many adds a new line by tabbing on a not dirty lineVincent Schippefilt
Before this change, when the focus was on the first field on a x2many field, and the user pressed TAB, the line would be discarded and the focus moved to the next field (at the level of the x2many) in the form. This was an issue because if the first field was required, the focus could not be moved out of the field with TAB so the user had to discard the line manually (with ESC) before moving to the next field This change works with 2 changes: 1. detecting if a line is dirty (has been modified by the user) and at the end of the line, decide to either - discard the line and move the next field, if the line is not dirty - commit the line and add a new line, if the line is dirty 2. allow users to use TAB through required field inside x2many so they can easilly go to the end of the line. Task id : 1872248