odoo通过iframe插入html页面

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dszgf5717/article/details/56302214

1、文件结构


2、js.xml文件

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data>
        <template id="assets_backend" name="sales_extend assets" inherit_id="web.assets_common">
            <xpath expr="." position="inside">
                <script type="text/JavaScript" src="/sales_extend/static/js/sales_extend.js"></script>
            </xpath>
        </template>
   </data>
</odoo>


3、sale_extend.js
/**
 * Created by badboy on 2017/1/10.
 */
var url = '';

function check_url() {
	if ( url != window.location.href ) {
		var id = getQueryString('id');
		var model = getQueryString('model');
		var view_type = getQueryString('view_type');
		if (view_type == 'form' && model == 'sale.order') {
			var myiframe = document.getElementById("myiframe");
			if (myiframe != null)
				myiframe.src = '/loadfile?id=' + id;
		}
		url = window.location.href;
	}
}

function getQueryString(name) {
	var reg = new RegExp("(^|&|#)" + name + "=([^&]*)(&|$)", "i");
	var r = window.location.href.match(reg);
	if (r != null) return unescape(r[2]); return null;
}

setInterval(check_url, 1000);

4、view.xml部分代码

<notebook position="replace">
    <group>
        <field name="project_file" string="下载地址"/>
    </group>
    <group>
        <iframe id="myiframe" src="/loadfile" frameBorder="0" width="100%" scrolling="no"></iframe>
    </group>
</notebook>


没有更多推荐了,返回首页