This question has been flagged

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?

Avatar
Discard
Best Answer

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.

 

Avatar
Discard