1 openerp.google_calendar = function(instance) {
2 var _t = instance.web._t,
3 _lt = instance.web._lt;
4 var QWeb = instance.web.qweb;
6 instance.web_calendar.FullCalendarView.include({
7 view_loading: function(r) {
9 this.$el.on('click', 'div.oe_cal_sync_button', function() {
10 console.log("Launch synchro");
11 self.sync_calendar(r);
13 return this._super(r);
15 sync_calendar: function(res,button) {
17 var context = instance.web.pyeval.eval('context');
18 //$('div.oe_cal_sync_button').hide();
19 $('div.oe_cal_sync_button').prop('disabled',true);
21 self.rpc('/web_calendar_sync/sync_calendar/sync_data', {
25 fromurl: window.location.href,
30 if (o.status == "NeedAuth") {
31 alert(_t("You will be redirected on gmail to authorize your OpenErp to access your calendar !"));
32 window.location = o.url;
34 else if (o.status == "NeedConfigFromAdmin") {
35 alert(_t("Admin need to configure Google Synchronization before to use it !"));
36 window.location = o.url;
38 else if (o.status == "NeedRefresh"){
39 self.$calendar.fullCalendar('refetchEvents');
42 }).always(function(o) { $('div.oe_cal_sync_button').prop('disabled',false); });
46 instance.web_calendar.FullCalendarView.include({
47 extraSideBar: function() {
49 if (this.dataset.model == "crm.meeting") {
50 var button = QWeb.render('GoogleCalendar.buttonSynchro');
51 this.$el.find('.oe_calendar_filter').prepend(button);