[FIX] web: on new ir actions act_window target current, change the active* params...
authorDenis Ledoux <dle@openerp.com>
Wed, 28 May 2014 13:50:02 +0000 (15:50 +0200)
committerDenis Ledoux <dle@openerp.com>
Wed, 28 May 2014 13:50:02 +0000 (15:50 +0200)
This fix is related to a37bad205b13cec4f19f8e84e28801278e3e36ca
This previous fix did solved the issue of its purpose, but had a side effect for actions using these active* params, e.g. search views
For instance, Go to Project > Projects, click on any project, you are than redirected to tasks/issues of this project
If you reload the page, an error pops up, complaining that active_id cannot be found

addons/web/static/src/js/views.js

index 228a0b3..196e8a1 100644 (file)
@@ -436,16 +436,6 @@ instance.web.ActionManager = instance.web.Widget.extend({
     ir_actions_act_window: function (action, options) {
         var self = this;
 
-        if (action.target === 'current'){
-            action.context['active_model'] = action.res_model;
-            if (action.res_id){
-                action.context['active_id'] = action.res_id;
-                action.context['active_ids'] = [action.res_id];
-            } else{
-                delete action.context['active_id'];
-                delete action.context['active_ids'];
-            }
-        }
         return this.ir_actions_common({
             widget: function () { return new instance.web.ViewManagerAction(self, action); },
             action: action,
@@ -892,7 +882,20 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
         this._super(parent, null, action.views, flags);
         this.session = parent.session;
         this.action = action;
-        var dataset = new instance.web.DataSetSearch(this, action.res_model, action.context, action.domain);
+        var context = action.context;
+        if (action.target === 'current'){
+            var active_context = {
+                active_model: action.res_model,
+            };
+            context = new instance.web.CompoundContext(context, active_context).eval();
+            delete context['active_id'];
+            delete context['active_ids'];
+            if (action.res_id){
+                context['active_id'] = action.res_id;
+                context['active_ids'] = [action.res_id];
+            }
+        }
+        var dataset = new instance.web.DataSetSearch(this, action.res_model, context, action.domain);
         if (action.res_id) {
             dataset.ids.push(action.res_id);
             dataset.index = 0;