I'd like to append a template in between KanbanView.buttons and KanbanView.Group to show description field in "project.project" model when I view "project.task" kanban view.
I guess there should be somewhere to append those templates into kanban view but unfortunately, I cannot find it.
What I did is
I created a custom template layouts.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<templates>
<t t-name="eric-kanban-view">
<div>This is Eric's kanban view</div>
</t>
</templates>
</data>
</openerp>
and I'd like to add the template to "project.view_task_kanban" to locate above kanban view project.xml
<record id="project_task_custom_kanban" model="ir.ui.view">
<field name="inherit_id" ref="project.view_task_kanban"/>
<field name="model">project.task</field>
<field name="arch" type="xml">
<xpath expr="//templates" position="before">
<t t-call="eric-kanban-view"/>
</xpath>
</field>
</record>
openerp.py
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name' : 'project_customized',
'version' : '1.1',
'author' : "Eric Lee",
'description': 'eric\'s Project customized module',
'installable' : True,
'data' : [
'project.xml',
],
'depends' : [
'project',
],
'qweb': [
'static/src/xml/layouts.xml',
'static/src/xml/project.xml',
],
}
But nothing happened.
Below is the layout I want
You need to create a widget by extending kanbanView.
Here is the example:
Here is the sample code.
static/src/xml/template.xml
<template id="template" xml:space="preserve">
<t t-name="kanban.sample_header">
<div class="sample_header" style="width:100%;height:50px;background-color:#fff;">
<h2>Sample header</h2>
</div>
</t>
</template>
static/src/js/sample.js
odoo.define('kanban.sample_dashboard', function (require) {
"use strict";
var core = require('web.core');
var formats = require('web.formats');
var Model = require('web.Model');
var session = require('web.session');
var KanbanView = require('web_kanban.KanbanView');
var QWeb = core.qweb;
var _t = core._t;
var _lt = core._lt;
var sampleHeader = KanbanView.extend({
display_name: _lt('Dashboard'),
icon: 'fa-dashboard',
fetch_data: function() {
// Overwrite this function with useful data
return $.when();
},
render: function() {
var super_render = this._super;
var self = this;
return this.fetch_data().then(function(result){
self.show_demo = result && result.nb_opportunities === 0;
var sales_dashboard = QWeb.render('kanban.sample_header', {
widget: self,
show_demo: self.show_demo,
values: result,
});
super_render.call(self);
$(sales_dashboard).prependTo(self.$el);
});
},
});
core.view_registry.add('sample_header', sampleHeader);
return sampleHeader;
})
view.xml
<odoo>
<data>
<template id="assets_backend" name="sample_header" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/kanban/static/src/js/sample_js.js"></script>
</xpath>
</template>
<record model="ir.ui.view" id="view_task_kanban_inherit">
<field name="name">project.task.kanban.inherit</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_kanban"/>
<field name="arch" type="xml">
<xpath expr="//kanban" position="attributes">
<attribute name='js_class'>sample_header</attribute>
</xpath>
</field>
</record>
</data>
</odoo>
Hope this will help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With