summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/services/data_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>
2018-12-11[FIX] *: JS doc/docstring errors & warningsXavier Morel
closes odoo/odoo#29439
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-01-26[REF] web,*: move fvg processing from DataManager to ViewsGéry Debongnie
*: mail, web_diagram
2018-01-22[MERGE] forward port branch 11.0 up to 950d9b23690Christophe Simonis
2018-01-15[FIX] web: disable {bin_size: true} on binary fieldsAlexandre Kühn
Revision on 41fe7f9d1113d026b226b136b4477aaaf9f1f638 This commit intended to reduce the network load when reading records with binary fields. This was made possible by enforcing the contextual key `bin_size` to be set for records with binary fields. However, it is causing some issues (see #22222, #22231) which are: - write with bin_size:true generates a traceback - read/search_read with bin_size:true breaks some images on some views (e.g. base.view_partner_form) Since the problems outweight the gain of these changes, we revert them.
2018-01-12[MERGE] forward port branch 11.0 up to 3b80a059ff4Christophe Simonis
2018-01-12[FIX] web: contexts on field widgets + enforce bin_size for binaryAlexandre Kühn
Field widgets now have a key 'context' that let them extend the context of the dataPoint (e.g. list). In particular, widgets on binary fields enforce the contextual item {bin_size: True}, so that the server gives the size of the binary field as its value, instead of its content. This change on binary fields reduces network load when accessing a view with binary fields.
2018-01-10[MERGE] forward port branch 11.0 up to ff0abd214c8Christophe Simonis
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
2017-11-28[MERGE] forward port branch 11.0 up to 8fb25e185bbChristophe Simonis
2017-11-28[MERGE] forward port branch saas-16 up to 3f66814a0d0Christophe Simonis
2017-11-23[REF] web,*: give evaluated contexts to load_viewsAaron Bohy
*board,sale_timesheet This rev. changes the API of load_views, as it now assumes that the given context has no longer to be evaluated. This is more convenient that way, as we can now call load_views with contexts that are dict, and not instances of the Context class.
2017-11-21[FIX] web: fieldDependency should be in fields tooLucas Perais (lpe)
Commit f45edfbe6d03b15977392dda9561cd7a3e16ce34 fixed a bug on image fields but was a partial fix. The problem is that while adding field dependencies to fieldsInfo, it did not add them in the fields of the view, making the view crash. After this commit, views and subviews contain fieldDependency as both info and actual fields of the view OPW 780021, 781620, 779649 [FIX] web: tests on many2many subviews closes #20891
2017-11-09[MERGE] forward port branch saas-16 up to 82add438f21Christophe Simonis
2017-11-08[FIX] web: fields set in fieldDependencies should have their "options" setLucas Perais (lpe)
Bug brought by f45edfb Before this commit, the debug manager crashed when clicking on "set defaults" on a view fetching a fieldDependency. This was because the "options" key on the field was not set when the field originated from the fieldDependency of a widget. After this commit, the data_manager ensures that key is present OPW 780071 closes #20730
2017-10-27[MERGE] forward port branch saas-16 up to 8fdac4b6b2fChristophe Simonis
2017-10-25[FIX] web: image widget is dependent on its record's last_updateLucas Perais (lpe)
As a way to optimize loading, images are not necessarily fetched in db. They have, in their url a "unique" parameter, which is the last_update date on **the record** and controls on the python-side whether it should get the image from a cache or from the db. Before this commit, this __last_update field wasn't present in the view, so it wasn't fetched, and writes on a model's image worked but did not refresh. The image displayed was the old one. After this commit, when the image field widget is present, we force the loading of the __last_update field of the record. Upon update, the image displayed is the new one. OPW 777552 closes #20457
2017-10-02[REF] stock: alert on show details if not savedSimon Lejeune
It's not possible to click on the show details button if the picking is not saved. It's a limitation of the webclient. This commit introduces a waring telling the user to save the form view first.
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-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-09-06[FIX] web: edit x2many editable list view after resequenceMartin Geubelle
In an embedded 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. To make this work, the list datapoint needs to be ordered by the field with the widget `handle` ; if it isn't, resequencing the records won't change the x2many data order but the list view expects the same order.
2017-09-01[FIX] web: BasicModel: correctly sort editable listsAdrien Dieudonne
This rev. fixes several issues with the sorting of dataPoints of type list in the BasicModel. First, only 'static' lists (i.e. x2many lists) must be sorted client-side, and results of search_read RPCs must remain unsorted as they are already retrieved sorted from the server. Second, editable and non-editable x2many lists don't behave the same with respect to sorting (we reproduced in this commit the behavior of saas-15). With editable lists, the edited rows are unsorted, except if the user explicitely ask for a sort (by clicking on a column header), until the form view is saved. With non-editable lists (as for x2many kanban), the sort is performed directly when a record is created or updated (as the edition is done from a dialog).
2017-08-29[FIX] web,mail: only send fields in view for onchangesAaron Bohy
The field 'display_name' is automatically added to the list of fields to fetch when fetching a record. Before this rev., its value was also sent alongside the fields in the view for onchange RPCs. It shouldn't: only the fields in the view should be sent. It produced a weird bug in the res.partner form view: open a contact (company), add a sub-contact, save -> the display_name of the contact was then '' (and 'Contacts' was displayed in the breadcrumbs instead of the display_name of the opened contact). This is because 'display_name' was sent to the onchange, which returned '' as value (because of another bug python side). So as it's value changed, when saving, the new display_name was sent to the server (even if this field was actually readonly). Before this rev., we also always fetched 'display_name' when fetching list of records (read or search_read). This wasn't a bug per se, but it might be a computed field, and it isn't necessary, so we stop fetching it in that case if it isn't in the view (as it was done in saas-15, before the new views).
2017-07-24[FIX] *: wrong `color_field` attribute for m2m_tagsAdrien Dieudonne
This fix previous commit a29f7f671b. (1) Some objects have no color field. (2) There was an issue when two many2many tags were instantiated: If the first one had the 'color_field' attribute the second one had it too even if this attribute weren't specified. Now, it's fixed in data_manager
2017-07-07[FIX] web: explicit color attribute for m2m_tagsMartin Geubelle
Before this fix, the field 'color' was hardcoded in the m2m_tags widget, which means that: - one couldn't specify another field (problem for custom models, with x_...) - if the related model didn't have the field 'color', a warning was raised by the server Now, the color attribute needs to be specified on the widget options if one wants to display colored tags. If the color is not specified, the tags will be displayed in grey.
2017-06-08[FIX] web: ModelFieldSelector: add a way to clear the cacheAaron Bohy
The ModelFieldSelector keeps an internal cache for the fields_get. This cache needs to be cleared in the tests environment because a model with the same name may be defined several times accross the tests modules, but they may contain different fields. This could also be a problem with studio: when a field is created, the ModelFieldSelector cache must be cleared as well (in addition to the data_manager one). We thus introduce a new 'clear_cache' event on core.bus. When triggered, the ModelFieldSelector and the data_manager clear their respective cache. We use this event in the test environment to ensure that the cache is cleared at the end of each test using a mockEnvironment. This rev. also fixes an infinite loop in the override of destroy() in the mockEnvironment, which occured when both session and config were specified in the params.
2017-05-11[FIX] web: deal with malformed `default_order`Martin Geubelle
Even if the `default_order` attribute should be like 'name,id desc,coucou' we want to support the syntax 'name, id desc, coucou' (i.e. with spaces after the comma). The commit also patches the mock server.
2017-05-04[FIX] web: deal wih `default_order` attributeMartin Geubelle
One could set the attribute `default_order` in the view arch (like 'name,id desc'). The records should then be sorted accordingly. This feature was not implemented in the new views. This attribute should work on both basic views and embedded views (x2many). The former uses the `sort` argument in `search_read` while the latter is sorted client-side. There is however a potential issue with the latter: as the order is done client-side with records received by the server, if there are more records than the limit, the server will send records without any order. The client side order will thus be done on a fraction of the records.
2017-05-02[FIX] web: don't fetch invisible relational fieldsAaron Bohy
Relational fields with attribute 'invisible' set to true are in views because they are used in domains or contexts. In this case their relational data is useless, only their ids matter. Before this rev., their relational data was fetched anyway. More precisely, it was the case for many2ones after a default_get, and for x2manys with inline views, or without view (e.g. with widget 'many2many_tags').
2017-04-24[REF] web: data_manager: define fields to fetch on a widgetMartin Geubelle
This commit modifies the way field widgets can specify the fields to fetch. Before this commit, a key `fetchSubFields` was used to fetch the `display_name` and the `color` in the many2manytag, but this behavior wasn't generic. A new key `fieldsToFetch` has now been introduced ; it should contain the definition of all fields to fetch.
2017-04-19[FIX] web: data_manager: replace `call_kw` session.rpcMartin Geubelle
`rpc.query` is an helper for `call_kw` session.rpc. This helper will, for example, add the mandatory `kwargs`.
2017-04-11[REF] barcode, *: update code to new JS frameworkChristophe Matthieu
With the new views, the barcode mechanisms were completely broken, because the view and widget JS code was totally changed. This commit update and refactor all that code to make it work with the new design philosophy. Also, it update the coding style.
2017-04-11[FIX] web,mail: one2many records: multiple viewsAaron Bohy
A record of the basic model may need to be displayed in different views (e.g. a o2m record is displayed in the, e.g., Kanban view inside the main form view, and if clicked, it is also displayed in the form view opened in a dialog). However, the fields present in those views may differ. The previous implementation of fieldsInfo in the record didn't handle that, as it was a dict whose keys were field names. With this commit, the fieldsInfo is dict whose keys are view types, and the values are dicts whose keys are field names (the fields of the corresponding views, with they attrs in the view). This allows to create multiple o2m records in a row in a form view.
2017-04-11[REM] web: remove id widgetDavid Monjoie
The original reason why this widget was created is because sometimes, the id is a virtual one, represented by string in the webclient. As such, the integer widget could not render it properly since it could not parse the integer from the string. This led to the following bug, which in turn led to the creation of the id widget: https://bugs.launchpad.net/openerp-web/+bug/919184 Now, virtual ids are not handled within the record data itself anymore, making it a non-issue to render the id field in the webclient since it is not given a value until a proper id is created. The virtual id management is completely out of the view scope now, rendering this widget useless.
2017-04-11[REF] web: use many2many tag widget in kanbanMartin Geubelle
Some commits haven't been correctly forward-ported, like https://github.com/odoo/enterprise/commit/2a3494a005f38baf2fd3db2c23844129e969e464 or https://github.com/odoo/enterprise/commit/5664a19045abed0cf900ef255bd3c96e16e8886c There purpose is to use the many2many tag widget in the kanban renderer instead of custom manipulation. The tests have also been adapted to correspond to the new tags.
2017-04-11[IMP] web: data_manager: make field description self-containedAaron Bohy
The fields are represented as an Object whose keys are the field names and values their description. By adding the name inside the description, this commit makes it fully self-contained. This commit also moves the processing of fields_views s.t. they are stored processed in the cache, instead of processing them each time they were requested.
2017-04-11[FIX] web: don't overwrite the mode if existing in attributesChristophe Matthieu
2017-04-11[REF] web: change internal representation of fields and view meta datasChristophe Matthieu
* Data manager load_view returns a viewInfo object * ViewInfo contains: the arch, fields and fieldsInfo objects, and some extra informations * The fields come from the server and are frozen, without any view attributes (depend of the model). * The fieldsInfo contains every view attributes and informations.
2017-04-11[REF] web,*: remove 'web.model' and 'web.dataModelGéry Debongnie
Use this.rpc instead of Model object, with web.ajax if necessary. nb: EventDispatcherMixin include now the custom_events managment instead of widget
2017-04-11[REF] web, *: redesign all JS viewsGéry Debongnie
This commit introduce a full redesign of all JS views. We started basically from scratch. The goal was to unify all the various views under a common framework, to make them testable, to make then usable in different conditions (in studio, or in the frontend), and to make our lives easier. Some important points are: - we introduced new coding guidelines (camelCase, 80 chars width, ...) - we have a brand new testing framework (still QUnit based) - kanban view moved to the web addon - calendar view (formerly web_calender) moved to web as well - the tree view was removed - all new code should be documented We hope that this code is the start of a new era for the Odoo web client, we want to have a high quality codebase, well documented, well tested, well designed. Work done by the framework team: mostly aab, ged, chm, dmo, qsm
2016-03-18[IMP] openerp,web: cache of actions, fields(_views) and filtersAaron Bohy
Introduction of 'data_manager' service which handles meta-data related to actions and views (fields_views, fields and filters). Ideally, all RPCs to get that kind of information should go through data_manager, as it holds an internal cache.