summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_controller.js
diff options
context:
space:
mode:
authorGéry Debongnie <ged@odoo.com>2017-10-20 15:29:10 +0200
committerGéry Debongnie <ged@odoo.com>2017-10-20 17:14:10 +0200
commit635572b49d5b70a32b717cf2d52da49b10aac28e (patch)
treeb61517934491495d11208d0fed3186adc769d8d9 /addons/web/static/src/js/views/basic/basic_controller.js
parentfd65dbaa1fa2f0169f0b44c7fe90a35b4cb137b4 (diff)
[FIX] web: properly handle failures in onchanges
With the new views, we mainly focused on making them work. But we also need to be able to handle unusual cases, such as some RPC failing. An example of such a problem was the following: - a form view with a one2many with an onchange - edit mode, change a field in the one2many, click elsewhere - the onchange triggers, calls the server - it may happen that the server fails with a ValidationError - the onchange deferred fails, the line in the one2many is restored to the value known by the list renderer, which is the previous value (but the new value was applied to the model) - we now have a 'corrupted' state: clicking on save will send the invalid value, even though the UI displays the previous one. We solve this problem in this commit by making sure that the onchange deferred returned by the _performOnchange always succeed (or stays pending). If the rpc fails, the deferred will succeed with an empty dictionary. This means that the list renderer will be updated with the value from the model. Note that it may not be intuitive that a failure in the onchange is not seen as an error from the perspective of the _performOnChange, but I think that it still makes sense: - the validation/network errors are not really a concern of the UI. The UI just display the values entered by the user. - if an onchange fails (for example, because of a coding error), we do not really want to prevent the user from working. Also, when the onchange is performed, the initial change was already applied to the local data. Rollbacking them would be a more difficult task. Note that we also improve the mock server in this commit, to allow mocking failures.
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_controller.js')
0 files changed, 0 insertions, 0 deletions