首页 > 解决方案 > 覆盖视图:website_sign/static/src/xml/website_sign_common.xml

问题描述

我试图通过扩展来改变视图。

<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
    <div t-extend="website_sign.thank_you_dialog">
        <div t-jquery=".row o_promote_esign" t-operation="replace">
            <div class="row o_promote_esign">
            <div class="col-md-2">
                <img src="/website_sign/static/description/icon.png" alt="Document Sign" class="img img-responsive"/>
            </div>
            <div class="col-md-10">
                <h4>Do you also send documents to sign?</h4>
                It's easy, incredibly efficient and totally free: you just have to create an account.
            </div>
        </div>
        </div>
    </div>
</templates>

但它不起作用。有什么建议我应该改变什么?

标签: xmlodoo-11

解决方案


是的,你是在正确的方式。扩展视图后,您必须从 js 加载模板文件,如下所示:

    odoo.define('module_nm.js_nm', function (require) {
       'use strict';

        var core = require('web.core');
        var ajax = require('web.ajax');
        var qweb = core.qweb;
        var test = require('base_module_js_nm');

        test.include({   
           _loadTemplates: function(){                                
             return $.when(this._super(), 
           ajax.loadXML('/module_nm/static/src/xml/file_nm.xml', qweb))         
            },          
       });
    });

然后,您必须将此 js 文件添加到 assets.xml 文件中,如下所示:

<template id="tmpl_id" inherit_id="web.assets_frontend" name="Template name">        
    <xpath expr="//script[last()]" position="after">            
          <script type="text/javascript" 
                src="/module_nm/static/src/js/js_file_nm.js"></script>            
    </xpath>
</template>

愿这工作。谢谢你。


推荐阅读