summaryrefslogtreecommitdiff
path: root/addons/web/static/src
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2020-03-19 13:30:06 +0000
committerAaron Bohy <aab@odoo.com>2020-03-19 14:59:50 +0000
commit0b88e862a81ad8a8719e592190da7c52f9c01649 (patch)
tree3f2f53165698c6f7866044fc6d2d3f4cc471b5b3 /addons/web/static/src
parentb42e9c4547b174e5cf88458a6c1b72e456cd9093 (diff)
[FIX] web: editable list: activate correct field
We have an editable list with 4 fields: - fieldA (say boolean) - fieldB with readonly modifier, readonly iff fieldA is true - fieldC with readonly modifier, readonly iff fieldA is false - fieldD Add a new row to the list: fieldA being false by default, fieldC is readonly whereas fieldB isn't. Change the value of fieldA: fieldB becomes readonly, and fieldC is now editable. From that point, before this commit, clicking on fieldC activated fieldD (instead of fieldC). The bug occurred since 3fd7b20, which added a delay between the moment fields are re-rendered (and inserted at the end of allFieldWidgets) and the moment there previous instances are destroyed (and the new ones take their place in the list). So when several fields were re-rendered at the same time, the order in allFieldWidgets could not match the actual column order anymore, and cause issues like the one described above. Part of task 2210323 closes odoo/odoo#48039 X-original-commit: 89b9717c08e148ad94db17d8746faa2312b6a07a Signed-off-by: Michaƫl Mattiello <mcm-odoo@users.noreply.github.com> Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src')
-rw-r--r--addons/web/static/src/js/views/basic/basic_renderer.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_renderer.js b/addons/web/static/src/js/views/basic/basic_renderer.js
index c0d3e415321..1db59bbab41 100644
--- a/addons/web/static/src/js/views/basic/basic_renderer.js
+++ b/addons/web/static/src/js/views/basic/basic_renderer.js
@@ -812,6 +812,9 @@ var BasicRenderer = AbstractRenderer.extend(WidgetAdapterMixin, {
_rerenderFieldWidget: function (widget, record, options) {
// Render the new field widget
var $el = this._renderFieldWidget(widget.__node, record, options);
+ // get the new widget that has just been pushed in allFieldWidgets
+ const recordWidgets = this.allFieldWidgets[record.id];
+ const newWidget = recordWidgets[recordWidgets.length - 1];
const def = this.defs[this.defs.length - 1]; // this is the widget's def, resolved when it is ready
const $div = $('<div>');
$div.append($el); // $el will be replaced when widget is ready (see _renderFieldWidget)
@@ -819,9 +822,9 @@ var BasicRenderer = AbstractRenderer.extend(WidgetAdapterMixin, {
widget.$el.replaceWith($div.children());
// Destroy the old widget and position the new one at the old one's
+ // (it has been temporarily inserted at the end of the list)
+ recordWidgets.splice(recordWidgets.indexOf(newWidget), 1);
var oldIndex = this._destroyFieldWidget(record.id, widget);
- var recordWidgets = this.allFieldWidgets[record.id];
- let newWidget = recordWidgets.pop();
recordWidgets.splice(oldIndex, 0, newWidget);
// Mount new widget if necessary (mainly for Owl components)