Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
4 Risposte
10553 Visualizzazioni

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





Avatar
Abbandona
Autore Risposta migliore
    <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>


Avatar
Abbandona

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

Risposta migliore

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

Avatar
Abbandona
Risposta migliore

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

        });

    }

})

});

Avatar
Abbandona

Can you specify which Odoo version you are using?

Risposta migliore

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);
   },
});
Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
lug 19
4184
0
ago 19
2875
1
lug 19
267
1
mag 21
15788
1
apr 21
4439