Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
4301 Weergaven

I am using odoo v11. One boolean field is there in res.users object. Based on that field I want to load library in a calendar view. I have tried the following code, but this does not work. It will display an error like self._rpc is not a function.

var is_enable_custom_cal;
var CalendarView = require('web.CalendarView');

CalendarView.include({

    jsLibs: [],

    cssLibs: [],

    init: function (viewInfo, params) {

    var self = this; 

    this._super.apply(this, arguments);

        self._rpc({

            model: 'res.users',

            method: 'get_current_user_cal',

            args: [[]],

    }).then(function (result) {

    is_enable_custom_cal = result['is_enable_custom_cal'];

    if(is_enable_custom_cal){

    self.jsLibs.push('.../static/lib/fullcalendar.js');

    self.cssLibs.push('../static/src/css/fullcalendar.css');

              }else{

              self.jsLibs.push('/web/static/lib/fullcalendar/js/fullcalendar.js');

              self.cssLibs.push('/web/static/lib/fullcalendar/css/fullcalendar.css');

              }

            });

    },
    });
Some Help?

Avatar
Annuleer

I think you forget to define rpc in first of line on your file.

The rpc functions located in web module if you like to access rpc query and functions you should define below code.

var rpc = require('web.rpc');

We already did it to access calendar library in POS.

We’ll do it.

Auteur

web.rpc worked for me.Thanks.

Gerelateerde posts Antwoorden Weergaven Activiteit
2
mei 22
2471
1
sep. 21
20660
2
mei 24
2641
1
jun. 23
3534
0
feb. 23
2343