当我完成导入摘录时,如何重定向到会计面板



在odoo会计模块中,有一个导入银行对账单的选项。导入完成后,它会自动将您重定向到对账视图,但我想将其重定向到会计面板。

我发现重定向是由以下JavaScript代码完成的:

enterprise-13.0/account_bank_statement_import_csv/static/src/js/import_bank_stmt.js:58

exit: function () {
this.do_action({
name: _t("Reconciliation on Bank Statements"),
context: {
'statement_line_ids': this.statement_line_ids
},
type: 'ir.actions.client',
tag: 'bank_statement_reconciliation_view'
});
},

我曾尝试修改代码以重定向到会计仪表板,但没有成功。

exit: function () {
var self = this;
console.log("JavaScript redirection after importing");
// var model_obj = new instance.web.Model('ir.model.data');
// var view_id = false;
// model_obj.call('get_object_reference', ['ir.ui.view', 'account.account_journal_dashboard_kanban_view']).then(function (result) {
//     view_id = result[1];
// });
// console.log('view_id');
// console.log(view_id);
// this._rpc({
//     model: 'account.move',
//     method: 'redirect_return', // Python code that returns the data of the view action.
// }).then(function (result) {
//     self.do_action(result);
// });
this.do_action({
name: _t("Reconciliation on Bank Statements"),
context: {
'statement_line_ids': this.statement_line_ids
},
type: 'ir.actions.client',
tag: 'bank_statement_reconciliation_view'
});
},

请你帮忙。

您可以使用this._rpc获取视图id,然后调用do_action进行重定向。

self._rpc({
model: "ir.model.data",
method: 'get_object_reference',
args: ['account', 'view_account_invoice_report_graph']
}).then(function (result) {
self.do_action({
name: _t('Invoices Analysis'),
type: 'ir.actions.act_window',
res_model: 'account.invoice.report',
views: [[result[1], 'graph']],
view_mode: 'graph',
});
});  

您还可以使用动作外部id读取动作数据

self._rpc({
model: "ir.model.data",
method: 'get_object_reference',
args: ['account', 'action_account_invoice_report_all']
}).then(function (result) {
self._rpc({
model: "ir.actions.act_window",
method: 'read',
args: [[result[1]]]
}).then(function (actions){
self.do_action(actions[0]);
});
});

最新更新