summaryrefslogtreecommitdiff
path: root/addons/google_calendar/static/src
diff options
context:
space:
mode:
authorKersten Jeremy <jke@openerp.com>2014-05-14 10:28:10 +0200
committerKersten Jeremy <jke@openerp.com>2014-05-14 10:28:10 +0200
commit02be7aa65cb2fa06ab2d1fcd250a419015f3c674 (patch)
tree67e78104efd0cbb0dac42e4f8c771b24a2110c45 /addons/google_calendar/static/src
parent7564f528e0ba959807e995ff5134ec0b04e4cb3f (diff)
[IMP] Improve Calendar synchronization
- Use the new fields from calendar (renamed in 9398.1.7 trunk-cal-v8-jke) - Manage some google excpetions about token expiration - Manage some google excpetions about token revokation - Manage some google excpetions about 410 - Gone from google - Detect / Allow user to change the calendar and remove all old reference. - Use by default the since_modified for synchronization and not always a full (updatedTime in google) - Add some key for ir_parameters : 'calendar.week_synchro' : number of week to synchornize when we are in full mode 'calendar.block_synchro_attendee' : need to synchronize the attendees between google and openerp (creation of partner) 'calendar.block_since_synchro' : Always use the full synchro. (Can be forced in "one time" removing the last synchro from res_users form) 'calendar.debug_print' : _logger is more verbose - Pep 8 - Change behaviour of do_request to return a tuple with status raquest and response - Add field from token and synchro date in res_users view form
Diffstat (limited to 'addons/google_calendar/static/src')
-rw-r--r--addons/google_calendar/static/src/js/calendar_sync.js42
1 files changed, 29 insertions, 13 deletions
diff --git a/addons/google_calendar/static/src/js/calendar_sync.js b/addons/google_calendar/static/src/js/calendar_sync.js
index fdc4aeffb77..fc05ca05ab0 100644
--- a/addons/google_calendar/static/src/js/calendar_sync.js
+++ b/addons/google_calendar/static/src/js/calendar_sync.js
@@ -11,38 +11,54 @@ openerp.google_calendar = function(instance) {
});
return this._super(r);
},
- sync_calendar: function(res,button) {
+ sync_calendar: function(res, button) {
var self = this;
var context = instance.web.pyeval.eval('context');
//$('div.oe_cal_sync_button').hide();
- $('div.oe_cal_sync_button').prop('disabled',true);
-
+ $('div.oe_cal_sync_button').prop('disabled', true);
+
self.rpc('/google_calendar/sync_data', {
arch: res.arch,
fields: res.fields,
- model:res.model,
+ model: res.model,
fromurl: window.location.href,
- local_context:context
+ local_context: context
}).done(function(o) {
- if (o.status == "need_auth") {
+ if (o.status === "need_auth") {
alert(_t("You will be redirected on gmail to authorize your OpenErp to access your calendar !"));
instance.web.redirect(o.url);
}
- else if (o.status == "need_config_from_admin") {
-
- if (!_.isUndefined(o.action) && parseInt(o.action)) {
- if (confirm(_t("An admin need to configure Google Synchronization before to use it, do you want to configure it now ? !"))) {
- self.do_action(o.action);
+ else if (o.status === "need_config_from_admin"){
+ if (!_.isUndefined(o.action) && parseInt(o.action)){
+ if (confirm(_t("An admin need to configure Google Synchronization before to use it, do you want to configure it now ? !"))){
+ self.do_action(o.action);
}
}
- else {
+ else{
alert(_t("An admin need to configure Google Synchronization before to use it !"));
}
}
- else if (o.status == "need_refresh"){
+ else if (o.status === "need_refresh"){
self.$calendar.fullCalendar('refetchEvents');
}
+ else if (o.status === "need_reset"){
+ if (confirm(_t("The account that you are trying to synchronize (" + o.info.new_name + "), is not the same that the last one used \
+(" + o.info.old_name + "! )" + "\r\n\r\nDo you want remove all references from the old account ?"))){
+ self.rpc('/google_calendar/remove_references', {
+ model:res.model,
+ local_context:context
+ }).done(function(o) {
+ if (o.status === "OK") {
+ alert(_t("All old references have been deleted. You can now restart the synchronization"));
+ }
+ else if (o.status === "KO") {
+ alert(_t("An error has occured when we was removing all old references. Please retry or contact your administrator."));
+ }
+ //else NOP
+ });
+ }
+ }
}).always(function(o) { $('div.oe_cal_sync_button').prop('disabled',false); });
}
});