[FIX] web_editor: fix automatic editor context for RPCs

With https://github.com/odoo/odoo/commit/55131b8f5becdd3d4776f4c3e7e4288a0b185706,
we automatically add the known editor context (containing lang,
website_id, etc) when using the `this._rpc` method. Some RPCs needed
however to explicitely not send a value from this automatic context...
but this was not correctly implemented. This can now be achieved by
using the `noContextKeys` key in the `this._rpc`'s *options* parameter.

closes odoo/odoo#28322
This commit is contained in:
qsm-odoo
2018-10-31 15:50:45 +00:00
parent b2584e141b
commit 912d4c2d41
3 changed files with 10 additions and 2 deletions
@@ -44,7 +44,12 @@ var BodyManager = rootWidget.RootWidget.extend(ServiceProviderMixin, {
var route = event.data.args[0];
if (_.str.startsWith(route, '/web/dataset/call_kw/')) {
var params = event.data.args[1];
var options = event.data.args[2];
params.kwargs.context = _.extend({}, weContext.get(), params.kwargs.context || {});
if (options) {
params.kwargs.context = _.omit(params.kwargs.context, options.noContextKeys);
event.data.args[2] = _.omit(options, 'noContextKeys');
}
params.kwargs.context = JSON.parse(JSON.stringify(params.kwargs.context));
}
}
@@ -576,7 +576,9 @@ var RTEWidget = Widget.extend({
this._getEscapedElement($el).prop('outerHTML'),
$el.data('oe-xpath') || null,
],
context: withLang ? context : _.extend({}, context, {lang: undefined}),
context: context,
}, withLang ? undefined : {
noContextKeys: 'lang',
});
},
@@ -594,7 +594,8 @@ var ViewEditor = Widget.extend({
model: 'ir.ui.view',
method: 'write',
args: [[session.id], {arch: session.text}],
context: _.extend({}, weContext.get(), {lang: undefined}),
}, {
noContextKeys: 'lang',
}).then(function () {
self._toggleDirtyInfo(session.id, 'xml', false);
def.resolve();