summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/relational_fields.js
AgeCommit message (Collapse)Author
2018-09-03[FIX] web: tab selects first many2one entry without triggering spurious createlen-odoo
Suppose you select a customer for a sale order. You type the beginning of his name "think", and a name_search is triggered which finds matching results, with first result "Think Big Systems". There are three ways to select it: click, enter or tab. Now there can be a warning set on this customer ("Bad client, only accept cash", or "good client, offer discount"). In that case, clicking on tab would trigger the onchange displaying the warning, but it would also set floating to true, which means a dialog to create client "think" would appear. This happens if the onchange is delayed, and thus the call to reset the floating state is triggered only after the focusout completed, instead of before. Coauthored with @aab-odoo opw 1866619 opw 1874475
2018-07-03[FIX] web: Email attachment issueGoffin Simon
Steps to reproduce the bug: - Go on a SO and click on "Send by email" - Remove the attachment and click on "Add an attachment" - Choose an attachment A and remove it by clicking on the cross - Click on "Add an attachment" and choose the attachment A Bug: The attachment didn't appear in the modal. opw:1862482
2018-05-08[FIX] web: use correct href in link for m2oMohammed Shekha
With a better href, many2one in readonly mode can be opened in new tab. Related to task: #32919
2018-05-04[FIX] web: one2many form view with action buttonAaron Bohy
Assume a one2many field inside a form, displaying field A in its list view, and a field B in its (dialog) form view. Moreover, there is an action button in the dialog, which updates the value of B. Before this rev., B wasn't correctly reloaded when the button was clicked, because the BasicModel reloaded the fields on the list view (i.e. field A), whereas it should reload the fields in both views. This fix is twofold. First, we force the viewType to 'form' when the record is reloaded, instead of the default ('list'), so that fields in the form view are correctly reloaded. Second, when we open the form view in the dialog, we add the fields of the list view to the dict of fields of the form view, so that the form is aware of those fields and can ask the model to reload them (still without displaying them). Fixes #24189
2018-04-17[FIX] web: focus select in reference widgetMartin Geubelle
In the reference widget, the focus was always on the input (many2one) even though the first select (with the model) was not set. Thanks to @kaerdsar for the original PR. Partially closes #24070
2018-04-12[FIX] web: one2many: add new record with 'Save & New'Aaron Bohy
Consider the following scenario involving a one2many list (non editable) inside a form view: - click on 'Add an item', a model opens, - fill the fields and click on 'Save & Close', - reopen the freshly created record, - maybe make some changes (this is optional, but makes sense), - click on 'Save & New', - fill the fields and click on 'Save & Close', -> the second created record isn't added to the list. The problem comes from the fact that when the dialog is opened for the second time (in this case by clicking on a record), the 'save' handler registers an 'UPDATE' command. While this is correct for the 'Save & New' click (as we update an existing record), this isn't for the second record which doesn't exist yet, and thus requires an 'ADD' command. This rev. ensures that the two cases are handled in the 'save' handler given to the dialog. OPW 1829723
2018-04-05[FIX] web: no record abandon on discard from default_get/onchangeAlexandre Kühn
Before this commit, when some records were created from an `onchange`, we have the following weird behaviour: Suppose that this record has some required fields that are empty. When we click on this record, then somewhere else, the record disappears from the list. This is because the records contains invalid fields, and it is wrongfully assuming that the record to be discarded comes from "Add an item". A previous commit [1] fixed a bit this issue with `default_get`, but since it relied on a fragile heuristic, we decide to apply the correct fix with this commit. [1] https://github.com/odoo/odoo/commit/b09f0c99be2b13d33986414485556d87da186d65
2018-03-14[FIX] web: unselect current row before changing pageGéry Debongnie
The issue here is quite simple. If we are editing a multipage one2many field, then we click on the pager, we need to properly unselect the current row. If we do not do that, then we can enter invalid data. For example, assume that there is a readonly field. We click on add, it creates a (virtual) record with no value for that field. When we click on the pager, we select the next page, and bypass all validation.
2018-03-14[FIX] web: prevent issues with pager and x2m and limitGéry Debongnie
When we are in the process of adding a record, we do not want to update the pager count. The reason is that if the user is at the limit (so, 1-40/40, no pager visible), then click on add, there will be a pager shown with 1-40/41. Now, imagine that the record currently being added as a required field, and the user clicks on the pager. In that case, we need to discard the newly added record (bringing the total back to 40), then move to next page, which does not exist anymore. So, to fix this issue, we simply consider that a record being added does not count, from the point of view of the pager.
2018-03-01[FIX] web: prevent footer from being rerenderedGéry Debongnie
In some cases, the footer in a form view dialog could be duplicated. The reason was that the form view was rerendered completely, footer included, by the renderer, out of the formcontroller control (it is the formcontroller's job to move the footer buttons to the footer). A possible fix is to work on the form renderer to make it aware that the footer buttons are expected to be only rendered once, but it has the disadvantage to be a fix specific to this issue, and any other form view behaviour with some side effects may have the same issue. This commit tries to prevent the form view from rerendering itself completely in those cases. This also has the disadvantage of possibly not being a complete fix, if some edge cases are missed. However, I have the feeling that we still want to avoid rerendering the full view if possible.
2018-02-01[FIX] web: sequence handlers on modal's one2many listLucas Perais (lpe)
From a form view (say Bill of materials) Edit the form Click on a bom line Click on the external button that makes the product form pop up change the order of suppliers on that product Before this commit, a JS traceback was raised This was because the changing object was not present in the localData that the Model object holds or more accurately, it was not the **right** model object that was targetted and this was due to the propagation of the resequence event After this commit, no error is thrown, and the resequencing works as expected OPW 807196
2018-01-05[FIX] web: sort and onchange in tabbed editable x2mChristophe Matthieu
Two attempts of dealing with sorting (and resequencing) in tabbed (multi-pages) x2many editable lists (see odoo/odoo@c2563db and odoo/odoo@983c7ae) have been previously done, using a static attribute (`keepChangesUnsorted`) on the datapoint. This solution sadly only covers both cases separately, not if they are combined. Morever, onchanges were not correctly managed in neither of these two cases. A new approach is used here, by "freezing" and "unfreezing" the datapoint when needed, which is more flexible. Some modifications have been introduced: - when ordering a x2many, all records are now considered (and not only the records on the current page) ; an additional read is thus done on the sorted field for all records in the x2many relation - `setSort` is now asynchronous as a `read` might be needed
2018-01-02[FIX] web: Fix column_invisible issue (#21693)Sanjay Jamod
[FIX] web: Fix column_invisible issue This commit fixes an issue with the column_invisible attribute. When we choose product variant for BOM for any particular product, at that time from the BOM Lines column "Apply on Variants" is hidden, but when we unset product variant from BOM Form, at that time the column 'Variants" set to visible. but in this case, it is set to hidden always. PR 21693, OPW 779555
2017-12-22[FIX] web: upload file widget keep metadata freshNicolas Lempereur
When modifying files the a widget FieldMany2ManyBinaryMultiFiles would not keep its metadata (currently associating attachment to [url, allowUnlink]) up with current value. So with an attachment added after init: - clicking on it would error (because link is wrong) - deleting it would unlink attachment originating from from onchange The expected behavior is: - being able to download attachments - not unlinking attachment originating from onchange and this is what this commit fixes. opw-787746 closes #21813
2017-12-18[FIX] web: better mode handling, prevent useless work in some casesGéry Debongnie
Before this commit, the way mode was handled was not optimal. The end result was correct (the widget were properly created/displayed in edit/readonly as required), but useless work was done. In particular, if we have list/x2manys with widgets and modifiers, it could happen that widgets were created in edit mode, then destroyed and recreated in readonly mode. This could happen in some important views, for example, any view with a field many2many_tags with a readonly modifiers (pretty much all views handling taxes) In this commit, we add a 'editable' attribute to list renderer. This is necessary, because the list renderer is not actually editable when it is in a x2many in a form view which is in readonly mode. Also, we need to manage the distinction between the fact that a list view is editable, and the fact that some widgets are created in edit and other in readonly mode, depending on modifiers, and on which line is being edited. We also add a benchmark (courtesy of CHM) to be able to measure the performance impact of edit/readonly/onchange in a larger form view. Before this commit, running this form benchmark on my machine gave a number of 0.4 op/sec, and after, it increases to 1.26 op/sec, so a pretty large improvement.
2017-12-12[MERGE] forward port branch saas-16 up to a2ea4ba095cChristophe Simonis
2017-12-11[FIX] web: FieldMany2One: don't re-render if dirtyAdrien Dieudonne
The 'main_flow_tour' noticed an error that we had already corrected for the input fields. See here: @a71f2237 In fact the same error can occur in the many2one fields for the exact same reason. It's why the 'main_flow_tour' crashed at the following step: ".ui-menu-item > a:contains('the_flow.customer')"
2017-11-16[MERGE] forward port branch saas-16 up to 745d00362abChristophe Simonis
2017-11-15[FIX] web: fix issue with combination of o2m, m2m, and m2oGéry Debongnie
Consider this: a form view with a one2many list view. In the one2many list view, there is a many2one field. When opening the manyone in a modal form view, there is a many2many field. In that situation, clicking on 'Add a new record' on the many2many field had the unfortunate effect of interfering with the one2many field in the main form view, which caused a crash or the modal form view to close unexpectedly. The issue is that an event was simply not properly stopped at the proper location. This is usually not a big deal, but, as described above, it can be a problem in some cases.
2017-11-09[MERGE] forward port branch saas-16 up to 82add438f21Christophe Simonis
2017-11-08[FIX] web: prevent useless discard dialog from showing upGéry Debongnie
Here is a scenario that could cause an issue: - open a form view with a many2one - click on edit button - click on small external button for many2one. this opens a modal form view - click on save in the modal (without changing anything) - click on save in the main record - exit form view. this opens a discard dialog There were two issues here: - saving the modal dialog automatically marks the many2one field as changed. This was necessary to force reloading the data, because editing a sub value in the modal form view could have changed the display_name of the manyone field. However, this is not necessary when no change was done. - when saving a record, the _isDirty flag was reset to false only if an actual rpc was done. However, it may happen that the flag is set to dirty (for example, when modifying a value inside a many2one), but the main record has no changed fields. In this commit, we also remove the on_save handler in the formviewdialog. This is a small refactoring in a stable version, but no code currently use it, and I believe that it will make the code much easier to maintain (the previous code was really awkward), so I think that the tradeoff is acceptable.
2017-11-07[MERGE] forward port branch saas-16 up to 255478acbd6Christophe Simonis
2017-11-07[FIX] web: clear m2o input at creation cancelMartin Geubelle
After entering a value in a many2one, if one clicks somewhere else, a popup is opened to suggest the user to create (or not) a new record with the entered value. Before this rev, closing this popup resulted in an unclear situation where the input was still set with the entered value but the new record hadn't been created. This commit fixes this by clearing the input value if the record is not created. See task#36055
2017-10-31[MERGE] forward port branch saas-16 up to 810b6aa7600Christophe Simonis
2017-10-30[FIX] web: allow dropdown selection in m2oGéry Debongnie
Before this commit, many2one fields were not (fully) usable in a list view: if the user wrote some text, then when a dropdown with various choices opened, pressed the 'down' key (to select a choice), the down keypress caused a navigation move to the next line, which cancelled the selection. In this commit, we make the assumption that if the many2one dropdown is opened, then navigation moves are not what the user wants.
2017-10-25[MERGE] forward port branch saas-16 up to 7bfde6e05d1Christophe Simonis
2017-10-23[FIX] web: reordering lines using the handle widget triggers onchangeChristophe Matthieu
issue: When reorder each line trigger an onchange on the line (if they are an onchange linked to the field) and one onchange per line on the parent. Adding an option doNotNotifyChange to avoid the trigger on the parent.
2017-10-13[MERGE] forward port branch saas-16 up to 8ee9024a4c8Christophe Simonis
2017-10-12[FIX] web: fix display issue with fieldSelectionGéry Debongnie
When displaying a many2one values, in edit mode, the option did not properly display some characters.
2017-10-12[FIX] web, hr_timesheet_sheet: make m2o friendly-usable outside of viewsqsm-odoo
Before this commit, m2o external button was always floating outside the m2o main DOM element, on the right. This induced problems when using the m2o outside of views (like in Odoo Studio). Now, the m2o design is made so that this button is inside the m2o, except in form views where we expect the button to overflow in the tables' right paddings.
2017-10-10[MERGE] forward port branch saas-16 up to 88a9980b0c0Christophe Simonis
2017-10-09[FIX] web: clear input on clicking 'Create and Edit' from many2one fieldsKhoi Nguyen
We clear the input field when clicking 'Create and Edit' to ensure that the field is empty if the user chooses to cancel the record creation. If a record is indeed created, then the field value will still be updated.
2017-10-04[FIX] web: x2m quickcreate>no error but slowcreateNicolas Lempereur
When the quickreate fail and a slow create is used instead, don't display the error that happened as is done in kanban and calendar (following 0f7f3fc2f) quick create.
2017-09-30[FIX] web: Kanban: open record when a tag is clickedAaron Bohy
Kanban records with 'global click' feature activated should open the record in a form view when the corresponding card is clicked. Before this rev., it wasn't working if the user clicked on a tag of the kanban record, because of an unused click handler defined on the Many2ManyTags widget (preventing the global click feature from actually performing the global click). This rev. removes that handler in the KanbanFieldMany2ManyTags.
2017-09-30Revert "[IMP] web: filter when clicking on tags in Kanban"Aaron Bohy
This reverts commit b6ef149b as it seems that we don't want this feature ultimately (was confusing for users trying to open the record, but it filtered instead). Note that opening the record by clicking on a tag still doesn't work, but this is fixed by the next commit.
2017-09-29[IMP] web: x2m list: conditionnaly hide a columnfwi-odoo
This commit introduces a new way to hide a column in a x2m list view. The attribute 'tree_invisible' can be add in the field attrs in the x2m view definition. This attribute can use the 'parent' key to make a reference to the parent record (e.g. 'parent.id').
2017-09-29[FIX] web,mail: reset focus after onchange on x2manyAaron Bohy
Rev. 2728fe1 introduced an attempt of restoring the focus on the currently focused field in an x2many list after an onchange returned, and the list has been updated. However, it was often wrong (e.g. leaving a field by pressing tab/shift+tab, clicking on another field...) and reset the focus on an unexpected field. In addition to fixing this issue, this rev. also unifies the helper functions to get and set the cursor positions in an input or textarea, as they were duplicated between mail and web.
2017-09-28[FIX] web: review UI tag color systemqsm-odoo
- Kanban colors and tag colors are now the same - Tag color 0 (default) is now back to be the invisible kanban one - Same colorpicker for kanban and tags - Define correct number of colors (12 not 13) - Color 0 should be a neutral one (gray) - ...
2017-09-20[FIX] web: update x2manys when onchange add new lineGéry Debongnie
In this commit, we make sure that if an onchange in a x2many modifies another line, then the new data is properly shown. This is quite tricky, because the field x2many ignores the full extent of the changes. Also, we obviously want to preserve the editing state (focused field, ...) So, what we actually do is to rerender the full x2many (minus the new line) to make sure that we preserve the correct row order. Note: thanks to MGE for the test and some preliminary work.
2017-09-15[MERGE] forward port branch saas-17 up to ed901bedcb7Christophe Simonis
2017-09-15[FIX] web: deal with `can_create` and `can_write` option in M2OMartin Geubelle
The server postproccess the view to add attributes on many2one fields, i.e. `can_create` and `can_write`, according to access rights. These attributes are parsed by the client as string but should also be parsed by the many2one when evaluating them. The mock server has also been adapted to set these attributes.
2017-09-13[MERGE] forward port branch saas-17 up to 1e17035f71fChristophe Simonis
2017-09-12[FIX] web, account: display partner in reconciliationMartin Geubelle
When selecting a partner in the reconciliation widget, using the SelectCreateDialog (Search More), the partner wasn't correctly displayed. This was due to a difference between the change format of the many2one ; when using the dialog, only the `id` is sent (while the `id` and `display_name` are sent when using the many2one dropdown). These two behaviours are now standardized and both now send `id` and `display_name`. It has the advantage of sparing some `name_get`s called by the model because the `display_name` was missing. This change implies some refactoring where the SelectCreateDialog was used.
2017-09-12[MERGE] forward port branch saas-17 up to d08b4407be3Christophe Simonis
2017-09-11[FIX] web: click on many2many tag with no colorAaron Bohy
Before this rev., a traceback was raised when the user clicked on a many2many tag in a kanban view without color field. For instance, it was the case in the kanban view opened by clicking on the Lead/Opportunity section of the activities icon in the systray.
2017-09-06[FIX] web: edit editable list view after resequenceMartin Geubelle
In an editable list view with the widget `handle`, resequencing a record and try to edit it afterwards won't work. The selected record isn't the correct one, as if the resequencing had no impact. A small refactoring has been done to fix this because the resequence logic was placed in the ListController (but should logically be placed in the model). Several views are using the resequencing ; the code is thus now placed in the BasicModel. The list renderer state is then updated after the resequence. The resequencing and the line edition have been placed in a common mutex to avoid problems when the user tries to edit a record while the resequence rpc isn't finished yet.
2017-09-01[REF] web: allow to distinguish kanban/list x2m in LESSqsm-odoo
2017-08-31[IMP] web: filter when clicking on tags in KanbanParth Gajjar
This commit adds a feature to the widget Many2ManyTags for kanban views. When a tag is clicked, records are filtered on the given tag, in addition to the active filters in the search view.
2017-08-31[MERGE] forward port branch saas-17 up to fe77df3ba48Christophe Simonis
2017-08-30[IMP] web: onchange x2many with virtual id in create commandChristophe Matthieu
When an onchange modifies an x2many field, the line on which the user works remains in editable mode and the cursor is returned to the same position. The second argument of create command is a reference used to reactivate the edited line.