From 5b5100b3da79a58492d979851b0926ed13f478d1 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 22 Apr 2016 11:57:20 +0200 Subject: [PATCH] [FIX] web_kanban: many2many tags only displayed the first time This bug was a consequence of commit 6c57935 which introduced a JS cache of stuff like actions, fields_view... The fields_view being modified in place by the kanban_view (which is obviously not a good practice), it was able to identify its many2many fields only the first time the view was displayed, as from the second time, it received an already processed version of the fields_view in which is wasn't able to identify many2many fields. Thus, those fields were only displayed the first time the view kanban view was displayed. --- addons/web_kanban/static/src/js/kanban_view.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/web_kanban/static/src/js/kanban_view.js b/addons/web_kanban/static/src/js/kanban_view.js index e95b97874a4..a7b29235772 100644 --- a/addons/web_kanban/static/src/js/kanban_view.js +++ b/addons/web_kanban/static/src/js/kanban_view.js @@ -73,7 +73,8 @@ var KanbanView = View.extend({ this.grouped_by_m2o = undefined; this.relation = undefined; this.is_empty = undefined; - this.many2manys = []; + // Retrieve many2manys stored in the fields_view if it has already been processed + this.many2manys = this.fields_view.many2manys || []; this.m2m_context = {}; this.widgets = []; this.data = undefined; @@ -95,6 +96,13 @@ var KanbanView = View.extend({ var child = this.fields_view.arch.children[i]; if (child.tag === "templates") { transform_qweb_template(child, this.fields_view, this.many2manys); + // transform_qweb_template(), among other things, identifies and processes the + // many2manys. Unfortunately, it modifies the fields_view in place and, as + // the fields_view is stored in the JS cache, the many2manys are only identified the + // first time the fields_view is processed. We thus store the identified many2manys + // on the fields_view, so that we can retrieve them later. A better fix would be to + // stop modifying shared resources in place. + this.fields_view.many2manys = this.many2manys; this.qweb.add_template(utils.json_node_to_xml(child)); break; } else if (child.tag === 'field') {