Help

3

[odoo10] : How can i inherit the web editor template?

Hi Everyone,

How one can inherit the editor template to apply some css or modify existing css class?
 
I want to inherit "web_editor.editorbar" template of web_editor module.

- This is main/base template.

<templates id="template" xml:space="preserve">
    <!--=================-->
    <!-- Base components -->
    <!--=================-->

    <!-- Here is the sample example  -->
    <t t-name="web_editor.editorbar">
        <div id="web_editor-top-edit" class="o_css_editor">
            <div id="web_editor-toolbars"/>
            <form class="navbar-form text-muted">
                <button type="button" class="btn btn-sm btn-default" data-action="cancel"><i class="fa fa-times"/> Discard</button>
                <button type="button" class="btn btn-sm btn-primary" data-action="save"><i class="fa fa-floppy-o"/> Save</button>
            </form>
        </div>
    </t>
    
     <t>............</t>
     <t> ..........</t>
</templates>

<!-- This is what i did, replaced the italic element with span by inheriting the template. -->

<templates>
        <t t-extend="web_editor.editorbar">
            <t t-jquery=".navbar-form text-muted" t-operation="replace">
                <form class=".navbar-form text-muted">
                    <button type="button" class="btn btn-sm btn-default" data-action="cancel"><span class="fa fa-times"/> Discard </button>
                    <button type="button" class="btn btn-sm btn-primary" data-action="save"><span class="fa fa-floppy-o"/> Save</button>
                </form>
            </t>
        </t>
</templates>

- Loaded this xml in .js file, the reason to load using javascript is because through normal qweb paramenter of manifest file was not functioning to load this xml. here is below javascript code which i've used to load xml file.

odoo.define('module_name.editor_extension', function (require) {
'use strict';
var core = require('web.core');
var ajax = require('web.ajax');
var qweb = core.qweb;
ajax.loadXML('/module_name/static/src/xml/editor.xml', qweb);
});
- Call of javascript file in asset xml file
<template id="assets_editor" inherit_id="web_editor.assets_editor">
    <xpath expr="."><!-- External library bootstrap-colorpicker -->
       <script type="text/javascript" src="/module_name/static/src/js/web_editor.js"/>
    </xpath>
</template>


If any one has idea about the following template inheritance, would be really apprciated

Thanks in advance.

Best Regards,

Anil Kesariya


Avatar
Discard