[FIX] correctly update many2many in listview (web client)
authorPierre Verkest <pverkest@anybox.fr>
Thu, 6 Nov 2014 15:18:33 +0000 (16:18 +0100)
committerGéry Debongnie <ged@odoo.com>
Wed, 26 Nov 2014 14:42:34 +0000 (15:42 +0100)
Fixes the issue #1216 (follow the link for more information). The issue
was caused by a hack in list view: the magical suffix __display is used
in render_cell to determine if a many2many field should be updated. This
commit simply makes sure that old many2many fields + __display keys are
cleared.

A better way would be to redesign/refactor the list view to avoid that
hack in the first place.  But this would be a much more complex task.

addons/web/static/src/js/view_list.js

index 52124d5..f9c857c 100644 (file)
@@ -541,8 +541,9 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
                 self.records.remove(record);
                 return;
             }
-            _(_.keys(values)).each(function(key){
-                record.set(key, values[key], {silent: true});
+            _.each(values, function (value, key) {
+                record.set(key + '__display', false, {silent: true});
+                record.set(key, value, {silent: true});            
             });
             record.trigger('change', record);
         });