Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
8120 Visninger

I want to extend calendar view with a read-only field but I don't know how I can get this field in JS file.

I think I can use instance var:

openerp.web_calendar = function(instance) {
    var _t = instance.web._t,
    _lt = instance.web._lt;
    var QWeb = instance.web.qweb; 
    ...
 }

But I dont understand how it's working. If someone can help me.

Avatar
Kassér

Which field you want to make it readonly? or the calendar view ?

Forfatter

I want to set all the calendarView at ReadOnly. I create a module that do this. Anyway thanks for your answer.

Forfatter Bedste svar

I've found a solution:

openerp.readOnlyCalendar = function(instance){
    var module = instance.web_calendar // loading the namespace of the 'web_calendar' module

    module.CalendarView.include({
        init_scheduler: function() {
            var readonly =this.fields_view.arch.attrs.ReadOnly
            if(readonly){
                scheduler.config.readonly= true;
            }
            this._super();  // calling the original CalendarView.init_scheduler() method
        }
    });
};

I use this code in a custom module: lp:~eirhylien/server-env-tools/readOnlyCalendar

Avatar
Kassér
Related Posts Besvarelser Visninger Aktivitet
1
aug. 22
8101
0
jun. 25
238
2
jun. 25
324
0
apr. 25
799
2
jan. 25
1057