Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
4 Răspunsuri
10773 Vizualizări

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





Imagine profil
Abandonează
Autor Cel mai bun răspuns
    <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>


Imagine profil
Abandonează

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

Cel mai bun răspuns

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

Imagine profil
Abandonează
Cel mai bun răspuns

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();

        });

    }

})

});

Imagine profil
Abandonează

Can you specify which Odoo version you are using?

Cel mai bun răspuns

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);
   },
});
Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
iul. 19
4293
0
aug. 19
2983
1
iul. 19
267
1
mai 21
15913
1
apr. 21
4668