URL ACTION表面上看起来只是单简单的跳转下网页,实际上仔细看它的现之后也有一些特别的用法,代码如下
function _executeActURLAction(action, options) {
let url = action.url;
if (url && !(url.startsWith("http") || url.startsWith("/"))) {
url = "/" + url;
}
if (action.target === "download" || action.target === "self") {
browser.location.assign(url);
} else {
const w = browser.open(url, "_blank");
if (!w || w.closed || typeof w.closed === "undefined") {
const msg = _t(
"A popup window has been blocked. You may need to change your " +
"browser settings to allow popup windows for this page."
);
env.services.notification.add(msg, {
sticky: true,
type: "warning",
});
}
if (action.close) {
return doAction(
{ type: "ir.actions.act_window_close" },
{ onClose: options.onClose }
);
} else if (options.onClose) {
options.onClose();
}
}
}
1、检则是否是被block掉。
2、查看是否要关闭对话框,通过action的close设置。
3、是否设置了onClose, 这个onClose实际上是在前端使用。
具体使用方法如下:
def import_module(self):
self.ensure_one()
IrModule = self.env['ir.module.module']
zip_data = base64.decodebytes(self.module_file)
fp = BytesIO()
fp.write(zip_data)
res = IrModule._import_zipfile(fp, force=self.force, with_demo=self.with_demo)
return {
'type': 'ir.actions.act_url',
'target': 'self',
'url': '/odoo',
}