Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4 Trả lời
10554 Lượt xem

I need to set 'Everybody's Calendar' always check by default in the right side of odoo calendar. It's always on Administrator[Me] and i have to select 'everybody's calendar' to see the events.

Yenthe Van Ginneken said here https://www.odoo.com/fr_FR/forum/aide-1/question/where-is-the-code-for-the-everybody-s-calendars-boolean-in-the-calendar-app-150133 that the code for this is in _loadFilter but i can't figure how to do it.. Thank you!

I can't post a print, but here it is https://stackoverflow.com/questions/57115029/how-to-set-everybodys-calendar-by-default





Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất
    <record id="view_l10n_cu_calendar_event_calendar" model="ir.ui.view">
<field name="name">calendar.event.calendar</field>
<field name="model">calendar.event</field>
<field name="inherit_id" ref="calendar.view_calendar_event_calendar"/>
<field name="arch" type="xml">
<data>
<field name="partner_ids" position="replace" >
<field name="partner_ids"/>
</field>
</data>
</field>
</record>


Ảnh đại diện
Huỷ bỏ

Where do you implement this in order to make this work on V 10 please?

Câu trả lời hay nhất

Can you help me work out how to do this in v17? 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Was able to 'default' to the All option (Everything/Everybody) by manually toggling the checkboxes during initialization. This results in selection loading twice but acheives desired affect. Leaving here for others:


odoo.define('service.CalendarModel', function (require) {

    "use strict"


var waitFor = function(selector, callback) {

    var element = $(selector);

    if (element.length) {

        callback(element);

    } else {

        setTimeout(function() {

            waitFor(selector, callback);

        }, 100);

    }

};


var CalendarModel = require('web.CalendarModel')


CalendarModel.include({

    /**

     * @override

     */

    init: function (context) {

        this._super.apply(this, arguments)

        // This is a hack to select 'Everything/Everybod's calendars' filters by default (instead of just 'Username [Me]')

        waitFor('.o_calendar_filter_item', function(filters) {

            filters.map(function() {

                var isAll = $(this).data('value') === 'all';

                var checkbox = $(this).find('.custom-control input').get(0);

                if (checkbox && (isAll && !checkbox.checked) || (!isAll && checkbox.checked)) {

                    return checkbox;

                }

            }).click();

        });

    }

})

});

Ảnh đại diện
Huỷ bỏ

Can you specify which Odoo version you are using?

Câu trả lời hay nhất

here is my code for v14 . 

need to set "not_init" so it only calls on _loadFilter on initial load


var CalendarModel = require('web.CalendarModel')
CalendarModel.include({
   _loadFilter: function(filter){
       if (!filter.not_init){
           filter.not_init = true;
           filter.all = true;
       }
       return this._super(filter);
   },
});
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 19
4184
0
thg 8 19
2875
1
thg 7 19
267
1
thg 5 21
15788
1
thg 4 21
4439