diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-04-02 21:04:31 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 9100e675dfe7ae60ea3c8f1a5ef1e9a78a4ab4c6 (patch) | |
| tree | 08f98b2fe727ece38153afb99c99611baf2e9395 /addons/web/static/src/js/views/field_manager_mixin.js | |
| parent | 0f96189b7fbc481b21f0b7b7a2fdcb82916d6bae (diff) | |
[FIX] web: add support for discarding lines in o2m
This is not a complete work, but it introduces the basic infrastructure
to properly edit various more sophisticated editing behaviours.
The main focus of this commit is to handle discarding invalid lines in
one2many, potentially asking the user for confirmation. So, the
relevant methods have to be modified to return some deferred, because
the operation is now asynchronous.
Diffstat (limited to 'addons/web/static/src/js/views/field_manager_mixin.js')
| -rw-r--r-- | addons/web/static/src/js/views/field_manager_mixin.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/field_manager_mixin.js b/addons/web/static/src/js/views/field_manager_mixin.js index 10d0c06ad76..9fcd34ffee2 100644 --- a/addons/web/static/src/js/views/field_manager_mixin.js +++ b/addons/web/static/src/js/views/field_manager_mixin.js @@ -12,6 +12,7 @@ var BasicModel = require('web.BasicModel'); var FieldManagerMixin = { custom_events: { + discard_line: '_onDiscardLine', field_changed: '_onFieldChanged', load: '_onLoad', }, @@ -59,6 +60,19 @@ var FieldManagerMixin = { //-------------------------------------------------------------------------- /** + * In some case, we may need to remove an element from a list, without going + * through the notifyChanges machinery. The motivation for this is when the + * user click on 'Add an item' in a field one2many with a required field, + * then clicks somewhere else. The new line need to be discarded, but we + * don't want to trigger a real notifyChanges (no need for that, and also, + * we don't want to rerender the UI). + * + * @param {OdooEvent} event + */ + _onDiscardLine: function (event) { + this.model.removeLine(event.data.id); + }, + /** * This is the main job of the FMM: deciding what to do when a controlled * field changes. Most of the time, it notifies the model that a change * just occurred, then confirm the change. |
