[FIX] web: crashmanager wrong syntax of arrow function

arrow function used for error handler and error function is defined
inside inner function so this will get changed, need to use self,
also arrow function doesn't have its own arguments object,
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

Issue raised from following commit:
https://github.com/odoo/odoo/commit/2d6dc75a2cb5fa81189920d0f7fdc7b7f12132ab

task-2052484

closes odoo/odoo#35788

Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
Mohammed Shekha
2019-08-27 12:13:43 +00:00
committed by Pierre Masereel
parent e74c6ef86a
commit 6952ee18bc
6 changed files with 46 additions and 6 deletions
@@ -103,7 +103,7 @@ var stock_report_generic = AbstractAction.extend({
url: url_data.replace('output_format', 'pdf'),
data: {data: JSON.stringify(dict)},
complete: framework.unblockUI,
error: () => this.call('crash_manager', 'rpc_error', ...arguments),
error: (error) => self.call('crash_manager', 'rpc_error', error),
});
});
return this.$buttons;
@@ -53,8 +53,8 @@ ActionManager.include({
data: JSON.stringify([url, type]),
},
success: resolve,
error: () => {
this.call('crash_manager', 'rpc_error', ...arguments);
error: (error) => {
self.call('crash_manager', 'rpc_error', error);
reject();
},
complete: framework.unblockUI,
@@ -1941,7 +1941,7 @@ var FieldBinaryFile = AbstractFieldBinary.extend({
'download': true,
'data': utils.is_bin_size(this.value) ? null : this.value,
},
error: () => this.call('crash_manager', 'rpc_error', ...arguments),
error: (error) => this.call('crash_manager', 'rpc_error', error),
url: '/web/content',
});
ev.stopPropagation();
@@ -150,7 +150,7 @@ var PivotController = AbstractController.extend({
url: '/web/pivot/export_xls',
data: {data: JSON.stringify(table)},
complete: framework.unblockUI,
error: () => this.call('crash_manager', 'rpc_error', ...arguments),
error: (error) => this.call('crash_manager', 'rpc_error', error),
});
},
/**
@@ -178,7 +178,7 @@ var DataExport = Dialog.extend({
})
},
complete: framework.unblockUI,
error: () => this.call('crash_manager', 'rpc_error', ...arguments),
error: (error) => this.call('crash_manager', 'rpc_error', error),
});
},
/**
@@ -2205,6 +2205,46 @@ QUnit.module('ActionManager', {
testUtils.mock.unpatch(ReportClientAction);
});
QUnit.test('crashmanager service called on failed report download actions', async function (assert) {
assert.expect(1);
var actionManager = await createActionManager({
data: this.data,
actions: this.actions,
services: {
report: ReportService,
},
mockRPC: function (route) {
if (route === '/report/check_wkhtmltopdf') {
return Promise.resolve('ok');
}
return this._super.apply(this, arguments);
},
session: {
get_file: function (params) {
params.error({
data: {
name: 'error',
exception_type: 'warning',
arguments: ['could not download file'],
}
});
params.complete();
},
},
});
try {
await actionManager.doAction(11);
} catch (e) {
// e is undefined if we land here because of a rejected promise,
// otherwise, it is an Error, which is not what we expect
assert.strictEqual(e, undefined);
}
actionManager.destroy();
});
QUnit.module('Window Actions');
QUnit.test('can execute act_window actions from db ID', async function (assert) {