[FIX] web: use search_read instead of read on form reload and record reload in list...
authorDenis Ledoux <dle@openerp.com>
Wed, 26 Mar 2014 14:20:40 +0000 (15:20 +0100)
committerDenis Ledoux <dle@openerp.com>
Wed, 26 Mar 2014 14:20:40 +0000 (15:20 +0100)
bzr revid: dle@openerp.com-20140326142040-pls0dk2kd03z55ro

1  2 
addons/web/static/src/js/view_form.js
addons/web/static/src/js/view_list.js
addons/web/static/test/list-editable.js
addons/web/static/test/list.js

@@@ -966,10 -956,15 +967,16 @@@ instance.web.FormView = instance.web.Vi
                      {
                          context: {
                              'bin_size': true,
--                            'future_display_name': true
++                            'future_display_name': true,
++                            'active_test': false
                          }
                      }).then(function(r) {
-                         self.trigger('load_record', r);
+                         if (_.isEmpty(r)){
+                             self.do_action('history_back');
+                         }
+                         else{
+                             self.trigger('load_record', r[0]);
+                         }
                      });
              }
          });
Simple merge
@@@ -81,7 -81,7 +81,7 @@@ openerp.testing.section('editor', 
      test('toggle-edition-save', {
          asserts: 4,
          setup: function (instance, $s, mock) {
--            mock('test.model:read', function () {
++            mock('test.model:search_read', function () {
                  return [{id: 42, a: false, b: false, c: false}];
              });
          }
@@@ -183,6 -183,6 +183,15 @@@ openerp.testing.section('list.edition'
              }
              return [];
          });
++        mock('demo:search_read', function (args) {
++            // args[0][0] = ["id", "=", 42] 
++            // args[0][0] = 42
++            var id = args[0][0][2];
++            if (id in records) {
++                return [records[id]];
++            }
++            return [];
++        });
          mock('demo:fields_view_get', function () {
              return {
                  type: 'tree',
@@@ -316,11 -316,11 +325,13 @@@ openerp.testing.section('list.edition.o
          mock('demo:read', function (args, kwargs) {
              if (_.isEmpty(args[0])) {
                  return [];
--            } else if (_.isEqual(args[0], [1])) {
--                return [
--                    {id: 1, a: 'some value'}
--                ];
--            } else if (_.isEqual(args[0], [42])) {
++            }
++            throw new Error(JSON.stringify(_.toArray(arguments)));
++        });
++        mock('demo:search_read', function (args, kwargs) {
++            if (_.isEqual(args[0], [['id', '=', 1]])) {
++                return [{id: 1, a: 'some value'}];
++            } else if (_.isEqual(args[0], [['id', '=', 42]])) {
                  return [ {id: 42, a: 'foo'} ];
              }
              throw new Error(JSON.stringify(_.toArray(arguments)));
@@@ -18,8 -18,8 +18,11 @@@ openerp.testing.section('list.buttons'
                  return [
                      {id: 1, a: 'foo'}, {id: 2, a: 'bar'}, {id: 3, a: 'baz'}
                  ];
--            } else if (_.isEqual(args[0], [2])) {
--                // button action virtually removed record
++            }
++            throw new Error(JSON.stringify(_.toArray(arguments)));
++        });
++        mock('demo:search_read', function (args, kwargs) {
++            if (_.isEqual(args[0], [['id', '=', 2]])) {
                  return [];
              }
              throw new Error(JSON.stringify(_.toArray(arguments)));