diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-04-01 09:36:23 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 3662c7246f90e8a7ea67aa52c71afd0cede330de (patch) | |
| tree | f33e760477f85f5326e32afe7e877ac8054aa07e /addons/web/static/src | |
| parent | 7056ec1ac6e6c23231d9044bb60efc2a0bdb7ae2 (diff) | |
[FIX] web: unselect current row on one2many before doing something else
In a one2many, when we click on 'Add an item', we need to unselect the
current row. Otherwise, its changes will not be committed and it will
be in practice discarded.
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_model.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/list/list_editable_renderer.js | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index 9139906f982..8f20f46b1cf 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -167,7 +167,7 @@ var BasicModel = AbstractModel.extend({ }; return this._makeDefaultRecord(list.model, params).then(function (id) { list.count++; - list._changes = list.data.slice(0); + list._changes = list._changes || list.data.slice(0); if (position === 'top') { list._changes.unshift(id); } else { diff --git a/addons/web/static/src/js/views/list/list_editable_renderer.js b/addons/web/static/src/js/views/list/list_editable_renderer.js index 2460e52cfea..1c1ea35acf2 100644 --- a/addons/web/static/src/js/views/list/list_editable_renderer.js +++ b/addons/web/static/src/js/views/list/list_editable_renderer.js @@ -485,10 +485,14 @@ ListRenderer.include({ _onAddRecord: function (event) { // we don't want the browser to navigate to a the # url event.preventDefault(); + // we don't want the click to cause other effects, such as unselecting // the row that we are creating, because it counts as a click on a tr event.stopPropagation(); + // but we do want to unselect current row + this._unselectRow(); + this.trigger_up('add_record'); }, /** |
