[FIX] web: fix action context
Previously, we had to filter the context values to exclude some erroneous values we propagated earlier. This commit removes the earlier propagation of wrong values (the current record context when executing an action) and thus also removes the filtering of those values, which was actually removing useful values from the action context. The bug could be seen by following these steps: - Install crm and sale - Go to My Pipeline - Open an opportunity which has a customer set - Click on "New Quotation" action button - See that the customer is not set on the new quotation, it should be set by the default_partner_id value in the action context
This commit is contained in:
@@ -568,10 +568,11 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
|
||||
// Wrong default_* and search_default_* values will no give the expected result
|
||||
// Wrong group_by values will simply fail and forbid rendering of the destination view
|
||||
var ncontext = new Context(
|
||||
_.object(_.reject(_.pairs(_.extend({}, action_data.context, self.env.context)), function(pair) {
|
||||
_.object(_.reject(_.pairs(self.env.context), function(pair) {
|
||||
return pair[0].match('^(?:(?:default_|search_default_|show_).+|.+_view_ref|group_by|group_by_no_leaf|active_id|active_ids)$') !== null;
|
||||
}))
|
||||
);
|
||||
ncontext.add(action_data.context || {});
|
||||
ncontext.add({active_model: self.env.modelName});
|
||||
if (res_ids) {
|
||||
ncontext.add({
|
||||
|
||||
@@ -2369,8 +2369,8 @@ var BasicModel = AbstractModel.extend({
|
||||
* if given, this field's context is added to the context, instead of
|
||||
* the element's context (except if options.full is true)
|
||||
* @param {boolean} [options.full=false]
|
||||
* if true and fieldName given in options, the element's context
|
||||
* is added to the context
|
||||
* if true or nor fieldName or additionalContext given in options,
|
||||
* the element's context is added to the context
|
||||
* @returns {Object} the evaluated context
|
||||
*/
|
||||
_getContext: function (element, options) {
|
||||
@@ -2378,7 +2378,7 @@ var BasicModel = AbstractModel.extend({
|
||||
var context = new Context(session.user_context);
|
||||
context.set_eval_context(this._getEvalContext(element));
|
||||
|
||||
if (options.full || !options.fieldName) {
|
||||
if (options.full || !(options.fieldName || options.additionalContext)) {
|
||||
context.add(element.context);
|
||||
}
|
||||
if (options.fieldName) {
|
||||
|
||||
@@ -3519,10 +3519,13 @@ QUnit.module('Views', {
|
||||
'</sheet>' +
|
||||
'</form>',
|
||||
res_id: 2,
|
||||
viewOptions: {
|
||||
context: {some_context: true},
|
||||
},
|
||||
intercepts: {
|
||||
execute_action: function (e) {
|
||||
assert.deepEqual(e.data.action_data.context, {test: 2},
|
||||
"button context should have been evaluated and given to the action");
|
||||
"button context should have been evaluated and given to the action, without previous context");
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user