根据业务需要,需要显示某地址的报表等
- xml
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="iframe_manage.ReportViewerIframe">
<iframe style="width: 100%; height: 900px;" class="o_embed_iframe w-100"
alt="Report viewer"
t-att-src="url" allowFullScreen="true"
t-att-name="props.name"
t-on-error="onLoadFailed"/>
</t>
</templates>
<!--视图-->
<field name="name" widget="report_iframe" string=""/>
/** @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() {
debugger
let url = false;
if (this.props.record.data[this.props.name]) {
url ='http://www.baidu.com/s?wd=';
}
return url;
}
onl oadFailed() {
this.notification.add(_t("无法显示报表!"), {
type: "danger",
});
}
}
ReportViewerIframe.template = "iframe_manage.ReportViewerIframe";
registry.category("fields").add("report_iframe", {
component: ReportViewerIframe,
});
标签:web,url,notification,props,ReportViewerIframe,iframe,odoo,增加,import
From: https://blog.csdn.net/weixin_42464956/article/details/139620657