Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Why does my qWeb inheritance affect the base module from which I inherit?

By
Peter Nietz
on 6/18/14, 8:25 AM 1,366 views

I try to write a custom module where the web_kanban modul is inherited:

<template>
<t t-name="KanbanView">
    <div class="oe_kanban_view">
        <div class="oe_kanban_buttons"/>
        <table class="oe_kanban_groups">
        <tr class="oe_kanban_groups_headers">
            <td class="oe_kanban_dummy_cell"><div/></td>
        </tr>
        <tr class="oe_kanban_groups_records">
            <td class="oe_kanban_dummy_cell"><div/></td>
        </tr>
        </table>
    </div>
</t>
[...]
</template>

For testing reasons I only added a div tag with an ID to check if my changes are visible:

<t t-extend="KanbanView">
   <t t-jquery=".oe_kanban_view" t-operation="replace">
       <div class="oe_kanban_view">
           <div id="change_test"/>
           <div class="oe_kanban_buttons"/>
           <table class="oe_kanban_groups">
             <tr class="oe_kanban_groups_headers">
                <td class="oe_kanban_dummy_cell"><div/></td>
             </tr>
             <tr class="oe_kanban_groups_records">
                <td class="oe_kanban_dummy_cell"><div/></td>
             </tr>
           </table>
       </div>
   </t>
</t>

I works fine in my custom module, but also affects different views in openERP!

For example: If I check the kanban View of [Settings / Installed Modules] I will also find:

<div id="change_test"></div>

Can someone explain this behavior? Do I understand the inheritance right?

[EDIT]

At  http://doc.openerp.com/trunk/web/qweb/   I found this:

t-extend=template BODY

Parameters:

template (String) -- name of the template to extend

Works similarly to OpenERP models: if used on its own, will alter the specified template in-place; if used in conjunction with t-name will create a new template using the old one as a base.

But if i add a t-name like

<t t-extend="KanbanView" t-name="CustomKanbanView">

my custom template isn't used anymore. How do I tell openERP to use my CustomTemplate instead of the standard?

1
Ivan Yelizariev
On 6/19/14, 1:09 AM

It is not a typical inheritance, so it's not easy to do. But if you are really need it, you have to very serious modifications in javascript. Below I made only beginning.

 

I found "KanbanView" in a file web/addons/web_kanban/static/src/js/kanban.js

So, you can create another KanbanView with this js code:

instance.web.views.add('kanban2', 'instance.web_kanban.KanbanView2');

 

instance.web_kanban.KanbanView2 = instance.web_kanban.KanbanView.extend({template: "KanbanView"})

In order to use kanban2 you have to find a place in a web client where 'kanban' view is used and add there kanban2.

 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 6/18/14, 8:25 AM
Seen: 1366 times
Last updated: 3/16/15, 8:10 AM