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
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
3568
Lượt xem
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 2 24
|
2171 | ||
Creating a custom dashboard
Đã xử lý
|
|
8
thg 11 23
|
55912 | |
|
1
thg 5 23
|
4137 | ||
|
3
thg 1 21
|
5682 | ||
|
1
thg 5 24
|
3334 |