如何修改CalendarView minTime / maxTime / slotDuration?

时间:2019-07-12 15:21:20

标签: javascript fullcalendar odoo

我需要修改: SlotDuration至“ 00:10:00” minTime到'08:00:00' maxTime到'22:00:00' 不会弄乱原始代码

从我看到的内容来看,我需要带有要进行的更改的.js和.xml并将其放入assets_backend

call_calendar_change.xml

<odoo>
<template id="assets_backend name="assets_backend_new" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/anser_ricardo/static/src/js/change_calendar.js"></script>
</xpath>
</template>
</odoo>

change_calendar.js

odoo.define('anser_ricardo.call_calendar_change', function(require){
"use strict";
var CalendarView = require('web.CalendarView');
CalenderView.include({
minTime: '08:00:00'
maxTime: '22:00:00'
slotDuration: '00:10:00'
})
});

但是我显然没有用,我认为问题出在.js文件中,有人可以帮助我吗?我看到有2/3的人和我有相同的问题,但没有答案。 谢谢!

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: '08:00:00',
                maxTime: '22:00:00',
                slotDuration: '00:10:00',
            });
        },
    });
});