summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields/relational_fields.js
AgeCommit message (Collapse)Author
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.
2017-08-30[FIX] web: tab navigation in editable list with create="0"Aaron Bohy
Before this rev., when the user pressed 'TAB' in the last cell of the last row of an editable list with attribute create="0", a new line was added to the list, thus totally ignoring the attribute. Now, it goes back to the first cell of the first row instead, as it was before the new views. Closes #19053
2017-08-30[FIX] web: properly show kanban tags' textsqsm-odoo
Previous tag design was a colored block with a text on hover. This text was explicitely html-escaped as put as the 'title' attribute value. Since https://github.com/odoo/odoo/commit/89cbbe3b0d6800a89b4385965151ed368659424f: The text is now always shown and is thus naturally html-escaped by the jQuery `text` method... and should thus not be explicitely escaped before.
2017-08-28[REF] web: set new tags layout and designstefanorigano
2017-08-23[FIX] web: make "slow" create of m2o fields workqsm-odoo
There were some coding mistakes since some changes introduced by https://github.com/odoo/odoo/commit/d19671f0d0ff7189055cbe0794afed32f8a387e6
2017-08-22[FIX] web: advanced use of widget `reference`Martin Geubelle
The reference widget is also meant to be used on a char field, not only on a reference field. The rev. https://github.com/odoo/odoo/commit/a4e30a1b43d0b9acd76508d9e6c466cd1dbdffab removed the use of `field_utils.format.many2one` and replaced it by `_formatValue` to support this use case. The replacement wasn't complete as some occurences was remaining (in reset), which led to traceback when the widget was reset (impossible to create an External Identifier anymore). Also, the reference `_formatValue` wasn't correct as it was displaying the record `display_name` and not the reference field value ; this only makes sense for the External Identifier as its display name is the reference field value but it doesn't make any sense for other reference field. Last but not least, this commit implements the `onchange` and `default_get` for the reference field.
2017-08-03[FIX] web: return a deferred in m2o quick createMartin Geubelle
The rev. https://github.com/odoo/odoo/commit/99ae418bf24171fbc6bb27584059c27efb857e77 accidentally modified the `quickCreate` return value type, which was previously a deferred. This function is overriden in Studio to catch the deferred so the previous type has been restored.
2017-08-02[FIX] web: handle `mutexify` in standalone widgetsMartin Geubelle
The rev. https://github.com/odoo/odoo/commit/99ae418bf24171fbc6bb27584059c27efb857e77 introduced a trigger_up `mutexify` when quick creating a record in a many2one ; this broke the behaviour when the many2one was standalone (because it has no BasicController and mutexify is handled in the latter). An attempt to fix this issue has been made in the rev. https://github.com/odoo/odoo/commit/e83c3e2678500c9bf2c17b4d23ae9a294ebafaa7 by adding an option `standalone` in the field widget options. In this case, the action was directly executed instead of the trigger_up. While this correctly works, this implies that the option needs to be added in every standalone many2one (and only many2one as the others won't use the option), which is not very convenient. An other attempt is made in this rev. by moving the mutexify handler from the BasicController to the FieldManagerMixin ; as a widget that instantiates a field widget needs to extend this mixin, both cases will work and we won't need to specify the option anymore. This commit thus partially reverts the rev. https://github.com/odoo/odoo/commit/e83c3e2678500c9bf2c17b4d23ae9a294ebafaa7
2017-07-25[FIX] web: do not delete records for one2many with widget=many2manykujiu
Some one2many fields are called with a many2many widget to unlink records instead of delete them. But this behavior was modified with the new views and the records were deleted anyway. In this commit, we restore the previous behavior, and create a FORGET command in basic model to do that. Note that the widget='many2many' is a hack, and a better way to accomplish this is to use a new custom option. But this would be a fix for master (PR #18413)
2017-07-25[FIX] web: prevent crash in FieldReferenceElkasitu
Trying to display external identifiers would make the server crash because the method in charge of requesting the external id information would expect an object but it was being given a string and thus not computing the m2o_value for the record. This commit fixes this by changing FieldMany2One objects' m2o_value instatiation to use its _formatValue method to compute it, _formatValue is then overridden in FieldReference so that it properly handles both strings and objects to calculate its m2o_value and relation.
2017-07-18[FIX] web: Fix actions for widgets w/o controllersElkasitu
Execution of actions is usually done with trigger_up, which delegates the action execution to the widget's controller. This is troublesome for actions done on widgets that have no controllers, like widgets in Studio for example. The commit fixes this by adding a standalone option for AbstractFields, if the flag is true when instantiating a widget, the action will be called directly from within the widget object and will not be propagated upwards. A test to verify that this works properly has been added as well