如何禁用Odoo 10

时间:2018-03-19 19:59:13

标签: odoo-10

我已经扩展了CalendarView并且工作正常,但我无法避免重叠事件。我尝试扩展event_data_transform函数并将{' overlap':false}添加到新的fullCalendar事件对象,但它仍然重叠。以下是扩展的event_data_transform函数的完整代码:

    event_data_transform: function (evt) {
        var r = this._super(evt);

        r['overlap'] = false;
        r['selectOverlap'] = false;

        _.each(evt, function (val, key) {
            if (key === 'date_start' || key === 'date_stop' || key === 'all_day' || key === 'title' || key === 'id' || key === 'attendees') {
            }
            else {
                r[key] = val;
            }
        });

        return r;
    },

1 个答案:

答案 0 :(得分:0)

我回答了自己的问题。我希望它对某人有帮助。经过一些研究后,我发现了CalendarView停止重叠事件的方法。我扩展了get_fc_init_options()函数。在那里,可以将值设置为许多属性以更改fullCalendar行为;我以一些为例。代码是:

    get_fc_init_options: function () {
        var self = this;
        var init_dict = this._super();

        init_dict['allDaySlot'] = false;
        init_dict['eventOverlap'] = false;
        init_dict['eventSelectOverlap'] = false;
        init_dict['minTime'] = '08:00';
        init_dict['maxTime'] = '20:00';
        init_dict['businessHours'] = {
            start: '08:00',
            end: '20:00',
            dow: [1, 2, 3, 4, 5]
        };
        init_dict['selectConstraint'] = 'businessHours';
        init_dict['eventConstraint'] = 'businessHours';
        init_dict['select'] = function (start_date, end_date, all_day, _js_event, _view) {
            var now = moment()
            if (now.diff(start_date, 'minutes') > 0) {
                self.$calendar.fullCalendar('unselect');
                alert(_t("You may only schedule services on future moments."));
                return;
            }
            var data_template = self.get_event_data({
                start: start_date,
                end: end_date,
                allDay: all_day,
            });
            self.open_quick_create(data_template);
        };
        return init_dict;
    },