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:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
3572
أدوات العرض
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
1
فبراير 24
|
2173 | ||
Creating a custom dashboard
تم الحل
|
|
8
نوفمبر 23
|
55928 | |
|
1
مايو 23
|
4137 | ||
|
3
يناير 21
|
5683 | ||
|
1
مايو 24
|
3344 |