0

モデルkanbanのビューにいくつかのダッシュボードの値を追加しようとしています。ダッシュボードを参考にしましたmaintenance.teamhelpdeskしかし、期待どおりには機能しませんでした。これが私のコードです:

***.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>

ここに画像の説明を入力

4

1 に答える 1