From 5fc3979262c46217c0d566ddc1b1f3d47b9d69dc Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Tue, 21 Mar 2017 11:06:21 +0100 Subject: [PATCH] [FIX] web: Avoid double-fetching many2many tags in list views Before this patch, #15920 was happening. The problem was that calling `render_cell` produced a call to [`record.set(column.id + '__display', value)`][1], which triggers the `change` event, which called `render_record` the first time, which called again `render_cell` and produced the 2nd data fetch. After this patch, `render_record` is only called if there is some place where to put the result, which does not happen in those situations. There is still the problem that there is one call to name_get for each many2many widget found in a list view (instead of one per full view rendering), but at least they are not two calls! [1]: https://github.com/odoo/odoo/blob/5d17749ff47c02294d5ff2ae56bbcef9d082562e/addons/web/static/src/js/view_list.js#L1125 --- addons/web/static/src/js/view_list.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index ae1a7fa328f..8d83acab79d 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -977,7 +977,9 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web. $row = self.$current.children( '[data-id=' + record.get('id') + ']'); } - $row.replaceWith(self.render_record(record)); + if ($row.length) { + $row.replaceWith(self.render_record(record)); + } }, 'add': function (ev, records, record, index) { var $new_row = $(self.render_record(record));