[FIX] web: on launching ir_actions_act_window, reset the active_* params if the targe...
authorDenis Ledoux <dle@openerp.com>
Mon, 26 May 2014 15:05:02 +0000 (17:05 +0200)
committerDenis Ledoux <dle@openerp.com>
Mon, 26 May 2014 15:05:02 +0000 (17:05 +0200)
This commit is related to 8d496399336b4a97200f6f7b5907ed1c7b99970c and b88755c4317ac61fc8d0533162d4ed19082f3fab
When hitting buttons of type object, the active_model and active_id(s) were kept, and, therefore, when calling a feature using the active* args, this feature used the active* args from the previous action.
Nevertheless, concerning wizards, the active* args should be indeed the active* args of the previous action, as wizards expects to have the active* args from the previous action. Thus, we reset these active* args only when this is not a wizard (target === 'current')
For example, from a sales order, hit the 'view invoice' button, and on the invoice, hit the 'send by email' button: The active_id in the send by email wizard were the id of the sale order, not of the invoice

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

index dc9f706..228a0b3 100644 (file)
@@ -436,6 +436,16 @@ 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,