js
添加js代码,书写一个widget,进行使用
/** @odoo-module **/
import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
import { standardFieldProps } from "@web/views/fields/standard_field_props";
import { Component } from "@odoo/owl";
import { _t } from "@web/core/l10n/translation";
class ReportViewerIframe extends Component {
static props = { ...standardFieldProps };
setup() {
super.setup();
this.notification = useService("notification");
}
get url() {
let url = false;
debugger;
if (this.props.record.data.x_full_path) {
url = this.props.record.data.x_full_path;
}
console.log(url);
return url;
}
onl oadFailed() {
this.notification.add(_t("无法显示报表!"), {
type: "danger",
});
}
}
ReportViewerIframe.template = "iframe_manage.ReportViewerIframe";
registry.category("fields").add("report_iframe", {
component: ReportViewerIframe,
});
xml
添加xml模板
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="iframe_manage.ReportViewerIframe">
<iframe style="min-width: 100%; height: 100%;"
alt="Report viewer"
t-att-src="url"
t-att-name="props.name"
t-on-error="onLoadFailed"/>
</t>
</templates>
xml
在视图中添加widget,进行显示
<field name="x_name" widget="report_iframe" style="min-width: 100%; height: 700px;"/>
标签:web,嵌入,core,url,props,ReportViewerIframe,iframe,odoo,import
From: https://blog.csdn.net/weixin_42464956/article/details/140350455