diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-05-05 15:21:36 +0200 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-05-08 08:10:00 +0200 |
| commit | c04b840a45edd222c50e74d18e2d02a3dd3175cd (patch) | |
| tree | cde51a1ba7c2eb0d869b9be711e8011158fb85fd /addons/web/static/src/js/fields/relational_fields.js | |
| parent | c75680c527844b3b984fa6dfbe04b612528cd9fb (diff) | |
[FIX] web: FieldMonetary: don't loose focus after edition
... in x2many editable list views.
Field widgets can detect that they are at the origin of a
field_changed event, so that they don't re-render themselves when
they are being edited.
This didn't work for fields inside x2many list views. This wasn't
a big problem for most of the fields, because the cursor position
was automatically reset after a re-rendering, but it wasn't
working for monetary fields that empty their $el before each
re-rendering.
This rev. fixes the issue by making the field widgets inside
x2many list able to detect that they are the origin of a change,
and thus removes the now useless code that restore the cursor
position.
Diffstat (limited to 'addons/web/static/src/js/fields/relational_fields.js')
| -rw-r--r-- | addons/web/static/src/js/fields/relational_fields.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index e9fa7dd09d1..db2db031a15 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -600,7 +600,7 @@ var FieldX2Many = AbstractField.extend({ if (command.operation === 'UPDATE') { var state = record.data[this.name]; var fieldNames = state.getFieldNames(); - this.renderer.confirmChange(state, command.id, fieldNames); + this.renderer.confirmChange(state, command.id, fieldNames, ev.initialEvent); return $.when(); } } @@ -787,12 +787,19 @@ var FieldX2Many = AbstractField.extend({ */ _onFieldChanged: function (ev) { if (ev.target === this) { + ev.initialEvent = this.lastInitialEvent; return; } ev.stopPropagation(); // changes occured in an editable list var changes = ev.data.changes; + // save the initial event triggering the field_changed, as it will be + // necessary when the field triggering this event will be reset (to + // prevent it from re-rendering itself, formatting its value, loosing + // the focus... while still being edited) + this.lastInitialEvent = undefined; if (Object.keys(changes).length) { + this.lastInitialEvent = ev; this._setValue({ operation: 'UPDATE', id: ev.data.dataPointID, |
