From 77b84341d88d32b9a0f3a9556174465c923adcac Mon Sep 17 00:00:00 2001 From: David Coninckx Date: Mon, 30 Mar 2015 16:38:18 +0200 Subject: [PATCH] Fix issue when query result not in the same order as values --- web_m2x_options/static/src/js/form.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/web_m2x_options/static/src/js/form.js b/web_m2x_options/static/src/js/form.js index fcdf7608..f5823623 100644 --- a/web_m2x_options/static/src/js/form.js +++ b/web_m2x_options/static/src/js/form.js @@ -120,10 +120,17 @@ openerp.web_m2x_options = function (instance) { .filter([['id', 'in', value_ids]]) .all().done(function (objects) { for (var index in objects) { - var value = values[index]; - // Find color with field value as key - var color = self.colors[objects[index][self.field_color]] || 'black'; - value.label = ''+value.label+''; + for (var index_value in values) { + if (values[index_value].id == objects[index].id) { + // Find value in values by comparing ids + var value = values[index_value]; + + // Find color with field value as key + var color = self.colors[objects[index][self.field_color]] || 'black'; + value.label = ''+value.label+''; + break; + } + } } def.resolve(values); });