+
+ // Check in the arch the fields to fetch on the stage to get tooltips data.
+ // Fetching data is done in batch for all stages, to avoid doing multiple
+ // calls. The first naive implementation of group_by_tooltip made a call
+ // for each displayed stage and was quite limited.
+ // Data for the group tooltip (group_by_tooltip) and to display stage-related
+ // legends for kanban state management (states_legend) are fetched in
+ // one call.
+ var group_by_fields_to_read = [];
+ var recurse = function(node) {
+ if (node.tag === "field" && node.attrs && node.attrs.options) {
+ var options = instance.web.py_eval(node.attrs.options);
+ var states_fields_to_read = _.map(
+ options && options.states_legend || {},
+ function (value, key, list) { return value; });
+ var tooltip_fields_to_read = _.map(
+ options && options.group_by_tooltip || {},
+ function (value, key, list) { return key; });
+ group_by_fields_to_read = _.union(
+ group_by_fields_to_read,
+ states_fields_to_read,
+ tooltip_fields_to_read);
+ }
+ _.each(node.children, function(child) {
+ recurse(child);
+ });
+ };
+ recurse(this.fields_view.arch);
+ var group_ids = _.map(groups, function (elem) { return elem.attributes.value[0]});
+ if (group_ids && group_by_fields_to_read) {
+ var group_data = new instance.web.DataSet(
+ this,
+ this.group_by_field.relation).read_ids(group_ids, _.union(['display_name'], group_by_fields_to_read));
+ }
+ else { var group_data = $.Deferred().resolve({}); }
+