使用js调用系统参数到FullCalendar

时间:2019-07-16 11:49:41

标签: javascript fullcalendar odoo-12

有没有一种方法可以在odoo系统参数中定义fullCalendar的minTime / maxTime / slotDuration,然后java将获取这些值并将Calendar设置为它?即设置3个系统参数(StartTime,StopTime和SlotDuration)并调用这些值。

我有这个:(感谢@Jigar Patel)

odoo.define('anser_ricardo', function(require){

"use strict";

var CalendarModel = require('web.CalendarModel');

CalendarModel.include({    

  _getFullCalendarOptions: function(){

    var res = this._super.apply(this, arguments);

    return _.extend(res, {

       minTime:  '08:00:00',

       maxTime: '22:00:00',

       slotDuration: '00:10:00',

});

},

});

});

我已经创建了3个系统参数:

<record id='start_time_key' model='ir.config_parameter'>
            <field name='key'>start_time_key</field>
            <field name='value'>08:00:00</field>
        </record>
        <record id='stop_time_key' model='ir.config_parameter'>
            <field name='key'>stop_time_key</field>
            <field name='value'>22:00:00</field>
        </record>
        <record id='slotDuration_time_key' model='ir.config_parameter'>
            <field name='key'>slotDuration_time_key</field>
            <field name='value'>00:10:00</field>
        </record>

我需要获取minTime / maxTime / slotDuration的值,而不是这样定义。 像这样:

 return _.extend(res, {

       minTime:  get.start_time_key,

       maxTime: get.stop_time_key,

       slotDuration: get.slotDuration_time_key,

有人可以帮忙吗?谢谢!

1 个答案:

答案 0 :(得分:1)

这是答案:

odoo.define('anser_ricardo', function (require) {

"use strict";

var CalendarModel = require('web.CalendarModel');

CalendarModel.include({

    _getFullCalendarOptions: function () {
        var res = this._super.apply(this, arguments);
            return _.extend(res, {
            minTime: this.custom_fc_options.start_time_key,
            maxTime: this.custom_fc_options.stop_time_key,
            slotDuration: this.custom_fc_options.slotDuration_time_key,
        });
    },
    _loadCalendar: function () {
        var self = this;
        var args = arguments;
        var sup = this._super;
        var defs = [];
        this.custom_fc_options = {};

        _.each(['start_time_key', 'stop_time_key', 'slotDuration_time_key], function (param) {
            var def = self._rpc({
                model: 'ir.config_parameter',
                method: 'get_param',
                args: [param]
            }).then(function (res) {
                self.custom_fc_options[param] = res;
            });
            defs.push(def);
        });

        return $.when.apply($, defs).then(function () {
            return sup.apply(self, args);
        });
    },

});

});