From 999c0b2cabb08496ffd60a56791151c76e4203fd Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Tue, 20 Nov 2012 11:06:20 +0100 Subject: [PATCH] [FIX] Modified behavior when we click on an action in the 'More' menu. Since revision 1517, when using the sidebar from a form view, it merged all the fields of the form view in the context of the action. It was modified to avoid that context pollution, now it only uses those fields to evaluate the context of that action. So it allows specifying contexts like "{'invoice_id': invoice_id}", but invoice_id will not be propagated any more to the new action context if not explicitely specified. bzr revid: nicolas.vanhoren@openerp.com-20121120100620-ig4e02uctysk7oj8 --- addons/web/static/src/js/view_form.js | 4 ++-- addons/web/static/src/js/views.js | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index c784b169d12..81987dc9e15 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1009,8 +1009,8 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } return true; }, - sidebar_context: function () { - return this.save().then(_.bind(function() {return this.get_fields_values();}, this)); + sidebar_eval_context: function () { + return $.when(this.build_eval_context()); }, open_defaults_dialog: function () { var self = this; diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 6fbbd3199ad..0478ba6abb0 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -1061,23 +1061,23 @@ instance.web.Sidebar = instance.web.Widget.extend({ }, on_item_action_clicked: function(item) { var self = this; - self.getParent().sidebar_context().done(function (context) { + self.getParent().sidebar_eval_context().done(function (sidebar_eval_context) { var ids = self.getParent().get_selected_ids(); if (ids.length == 0) { instance.web.dialog($("
").text(_t("You must choose at least one record.")), { title: _t("Warning"), modal: true }); return false; } - var additional_context = _.extend({ + var active_ids_context = { active_id: ids[0], active_ids: ids, active_model: self.getParent().dataset.model - }, context); + }; self.rpc("/web/action/load", { action_id: item.action.id, - context: additional_context + context: new instance.web.CompoundContext(sidebar_eval_context, active_ids_context), }).done(function(result) { - result.context = _.extend(result.context || {}, - additional_context); + console.log(result.context); + result.context = new instance.web.CompoundContext(result.context || {}, active_ids_context); result.flags = result.flags || {}; result.flags.new_window = true; self.do_action(result, { @@ -1330,7 +1330,7 @@ instance.web.View = instance.web.Widget.extend({ on_sidebar_export: function() { new instance.web.DataExport(this, this.dataset).open(); }, - sidebar_context: function () { + sidebar_eval_context: function () { return $.when(); }, /**