I am trying to add some dashboard values to `kanban` view of `maintenance.team` model. i used `helpdesk` dashboard for reference. But didn't work as expected.
Here is my code.
***.js**
odoo.define('maintenance_dashboard.dashboard',function (require){
"use strict";
console.log('Am here in dashboard js');
var core = require('web.core');
var KanbanController = require('web.KanbanController');
var KanbanModel = require("web.KanbanModel");
var KanbanRenderer = require('web.KanbanRenderer');
var KanbanView = require('web.KanbanView');
var session = require("web.session");
var view_registry = require('web.view_registry');
var Qweb = core.qweb;
var _t = core._t;
var _lt = core._lt;
console.log('KanbanRenderer',KanbanRenderer);
var MaintenanceDashboardRenderer = KanbanRenderer.extend({
/**
* @override
* @private
* @returns {Promise}
*/
_render: function(){
console.log('inside render function');
var self = this;
return this._super.apply(this,arguments).then(function (){
var values = self.state.dashboardValues;
console.log('values',values);
var maintenance_dashboard1 = Qweb.render('maintenance_dashboard.MaintenanceDashboard', {
widget: self,
// show_demo: values.show_demo,
// rating_enable: values.rating_enable,
// success_rate_enable: values.success_rate_enable,
values: values,
});
self.$el.prepend(maintenance_dashboard1);
});
},
});
console.log('after first function');
var MaintenanceDashboardModel = KanbanModel.extend({
/**
* @override
*/
init: function () {
this.dashboardValues = {};
this._super.apply(this, arguments);
},
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
/**
* @override
*/
__get: function (localID) {
var result = this._super.apply(this, arguments);
if (_.isObject(result)) {
result.dashboardValues = this.dashboardValues[localID];
}
return result;
},
/**
* @œverride
* @returns {Promise}
*/
__load: function () {
return this._loadDashboard(this._super.apply(this, arguments));
},
/**
* @œverride
* @returns {Promise}
*/
__reload: function () {
return this._loadDashboard(this._super.apply(this, arguments));
},
//--------------------------------------------------------------------------
// Private
//--------------------------------------------------------------------------
/**
* @private
* @param {Promise} super_def a promise that resolves with a dataPoint id
* @returns {Promise -> string} resolves to the dataPoint id
*/
_loadDashboard: function (super_def) {
var self = this;
var dashboard_def = this._rpc({
model: 'maintenance.team',
method: 'retrieve_dashboard',
});
return Promise.all([super_def, dashboard_def]).then(function(results) {
var id = results[0];
var dashboardValues = results[1];
self.dashboardValues[id] = dashboardValues;
return id;
});
},
});
var MaintenanceDashboardView = KanbanView.extend({
config:_.extend({},KanbanView.prototype.config,{
Model: MaintenanceDashboardModel,
Renderer: MaintenanceDashboardRenderer,
}),
display_name:_lt('Dashboard'),
icon:'fa-dashboard',
searchview_hidden:true,
});
view_registry.add('maintenance_dashboard1', MaintenanceDashboardView);
return {
Model: MaintenanceDashboardModel,
Renderer: MaintenanceDashboardRenderer,
};
});
**xml_template.xml**
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="maintenance_dashboard.MaintenanceDashboard">
<div>
<span> Am here</span>
</div>
</t>
</templates>
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
2782
Views
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Feb 24
|
991 | ||
Creating a custom dashboard
Solved
|
|
8
Nov 23
|
48275 | |
|
1
May 23
|
2828 | ||
|
3
Jan 21
|
4944 | ||
|
1
May 24
|
1434 |