[FIX] catch possible exception in search.js
authorGéry Debongnie <ged@odoo.com>
Wed, 8 Oct 2014 08:16:36 +0000 (10:16 +0200)
committerGéry Debongnie <ged@odoo.com>
Tue, 21 Oct 2014 07:33:51 +0000 (09:33 +0200)
The search view tries to evaluate the category of a filter in order
to put it in the filters or in the group by sub menu.  The pyeval.eval
function could throw an exception, which is not cool if it crashes the
client.  This fix make sure that the exception is caught.

addons/web/static/src/js/search.js

index 93de734..69bd4c1 100644 (file)
@@ -662,10 +662,12 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea
         function eval_item (item) {
             var category = 'filters';
             if (item.attrs.context) {
-                var context = instance.web.pyeval.eval('context', item.attrs.context);
-                if (context.group_by) {
-                    category = 'group_by';
-                }
+                try {
+                    var context = instance.web.pyeval.eval('context', item.attrs.context);
+                    if (context.group_by) {
+                        category = 'group_by';
+                    }                    
+                } catch (e) {}
             }
             return {
                 item: item,