diff --git a/addons/base_setup/models/res_config_settings.py b/addons/base_setup/models/res_config_settings.py
index acbe5a873c5..70bf35c0bcd 100644
--- a/addons/base_setup/models/res_config_settings.py
+++ b/addons/base_setup/models/res_config_settings.py
@@ -20,7 +20,7 @@ class ResConfigSettings(models.TransientModel):
module_google_calendar = fields.Boolean(
string='Allow the users to synchronize their calendar with Google Calendar')
module_microsoft_calendar = fields.Boolean(
- string='Allow the users to synchronize their calendar with Office 365 Calendar')
+ string='Allow the users to synchronize their calendar with Outlook Calendar')
module_google_drive = fields.Boolean("Attach Google documents to any record")
module_google_spreadsheet = fields.Boolean("Google Spreadsheet")
module_auth_oauth = fields.Boolean("Use external authentication providers (OAuth)")
diff --git a/addons/base_setup/views/res_config_settings_views.xml b/addons/base_setup/views/res_config_settings_views.xml
index 7398104b97f..b2c9a48f4cc 100644
--- a/addons/base_setup/views/res_config_settings_views.xml
+++ b/addons/base_setup/views/res_config_settings_views.xml
@@ -253,7 +253,7 @@
-
+
Synchronize your calendar with Outlook
diff --git a/addons/google_calendar/static/src/js/google_calendar.js b/addons/google_calendar/static/src/js/google_calendar.js
index b19bafea384..c7157aa359e 100644
--- a/addons/google_calendar/static/src/js/google_calendar.js
+++ b/addons/google_calendar/static/src/js/google_calendar.js
@@ -14,6 +14,24 @@ var _t = core._t;
const GoogleCalendarModel = CalendarModel.include({
+ /**
+ * @override
+ */
+ init: function () {
+ this._super.apply(this, arguments);
+ this.google_is_sync = true;
+ },
+
+ /**
+ * @override
+ */
+ __get: function () {
+ var result = this._super.apply(this, arguments);
+ result.google_is_sync = this.google_is_sync;
+ return result;
+ },
+
+
/**
* @override
* @returns {Promise}
@@ -35,6 +53,7 @@ const GoogleCalendarModel = CalendarModel.include({
},
_syncGoogleCalendar(shadow = false) {
+ var self = this;
var context = this.getSession().user_context;
return this._rpc({
route: '/google_calendar/sync_data',
@@ -43,7 +62,14 @@ const GoogleCalendarModel = CalendarModel.include({
fromurl: window.location.href,
local_context: context, // LUL TODO remove this local_context
}
- }, {shadow});
+ }, {shadow}).then(function (result) {
+ if (result.status === "need_config_from_admin" || result.status === "need_auth") {
+ self.google_is_sync = false;
+ } else if (result.status === "no_new_event_from_google" || result.status === "need_refresh") {
+ self.google_is_sync = true;
+ }
+ return result
+ });
},
})
@@ -115,12 +141,16 @@ const GoogleCalendarRenderer = CalendarRenderer.include({
this._super.apply(this, arguments);
this.$googleButton = $();
if (this.model === "calendar.event") {
- this.$googleButton = $('', {type: 'button', html: _t("Sync with Google")})
- .addClass('o_google_sync_button oe_button btn btn-secondary')
- .prepend($('', {
- src: "/google_calendar/static/src/img/calendar_32.png",
- }))
+ if (this.state.google_is_sync) {
+ this.$googleButton = $('', {html: _t("Synched with Google")})
+ .addClass('o_google_sync badge badge-pill badge-success')
+ .prepend($('', {class: "fa mr-2 fa-check"}))
.appendTo(self.$sidebar);
+ } else {
+ this.$googleButton = $('', {type: 'button', html: _t("Sync with Google")})
+ .addClass('o_google_sync_button oe_button btn btn-secondary')
+ .appendTo(self.$sidebar);
+ }
}
},
diff --git a/addons/google_calendar/static/src/scss/google_calendar.scss b/addons/google_calendar/static/src/scss/google_calendar.scss
index 1ee8feef473..54b5c82655f 100644
--- a/addons/google_calendar/static/src/scss/google_calendar.scss
+++ b/addons/google_calendar/static/src/scss/google_calendar.scss
@@ -1,10 +1,12 @@
.o_google_sync_button {
- display: block;
margin: auto;
> img {
margin-right: 10px;
}
}
+.o_google_sync.badge {
+ border: none;
+}
img.calendar_img_tuto {
margin: 0 0 10px 50px;
diff --git a/addons/google_calendar/static/tests/google_calendar_tests.js b/addons/google_calendar/static/tests/google_calendar_tests.js
index 5ec1e475af5..db98e22929f 100644
--- a/addons/google_calendar/static/tests/google_calendar_tests.js
+++ b/addons/google_calendar/static/tests/google_calendar_tests.js
@@ -70,7 +70,7 @@ QUnit.module('Google Calendar', {
}, function () {
QUnit.test('sync google calendar', async function (assert) {
- assert.expect(8);
+ assert.expect(9);
var calendar = await createCalendarView({
View: GoogleCalendarView,
@@ -105,12 +105,14 @@ QUnit.module('Google Calendar', {
assert.containsN(calendar, '.fc-event', 3, "should display 3 events on the month");
- await testUtils.dom.click(calendar.$('.o_google_sync_button'));
+ await testUtils.dom.click(calendar.$('.o_calendar_button_next'));
+ await testUtils.dom.click(calendar.$('.o_calendar_button_prev'));
assert.verifySteps([
'/google_calendar/sync_data',
'/web/dataset/call_kw/calendar.event/search_read',
'/google_calendar/sync_data',
+ '/web/dataset/call_kw/calendar.event/search_read',
'/google_calendar/sync_data',
'/web/dataset/call_kw/calendar.event/search_read',
], 'should do a search_read before and after the call to sync_data');
diff --git a/addons/microsoft_calendar/__manifest__.py b/addons/microsoft_calendar/__manifest__.py
index 763a1088803..03dd4d1fb56 100644
--- a/addons/microsoft_calendar/__manifest__.py
+++ b/addons/microsoft_calendar/__manifest__.py
@@ -9,6 +9,7 @@
'depends': ['microsoft_account', 'calendar'],
'qweb': ['static/src/xml/*.xml'],
'data': [
+ 'data/microsoft_calendar_data.xml',
'security/ir.model.access.csv',
'wizard/reset_account_views.xml',
'views/res_config_settings_views.xml',
diff --git a/addons/microsoft_calendar/data/microsoft_calendar_data.xml b/addons/microsoft_calendar/data/microsoft_calendar_data.xml
new file mode 100644
index 00000000000..f41a1d38316
--- /dev/null
+++ b/addons/microsoft_calendar/data/microsoft_calendar_data.xml
@@ -0,0 +1,18 @@
+
+
+
+
+ Outlook: synchronization
+
+ code
+
+model._sync_all_microsoft_calendar()
+
+
+ 12
+ hours
+ -1
+
+
+
+
diff --git a/addons/microsoft_calendar/models/microsoft_sync.py b/addons/microsoft_calendar/models/microsoft_sync.py
index 888fe09eff0..ea91094bff8 100644
--- a/addons/microsoft_calendar/models/microsoft_sync.py
+++ b/addons/microsoft_calendar/models/microsoft_sync.py
@@ -112,7 +112,7 @@ class MicrosoftSync(models.AbstractModel):
synced.write({self._active_name: False})
self = self - synced
elif synced:
- raise UserError(_("You cannot delete a record synchronized with Microsoft Calendar, archive it instead."))
+ raise UserError(_("You cannot delete a record synchronized with Outlook Calendar, archive it instead."))
return super().unlink()
@api.model
diff --git a/addons/microsoft_calendar/models/res_users.py b/addons/microsoft_calendar/models/res_users.py
index 7354ea45f44..dec51d171de 100644
--- a/addons/microsoft_calendar/models/res_users.py
+++ b/addons/microsoft_calendar/models/res_users.py
@@ -39,7 +39,7 @@ class User(models.Model):
client_secret = get_param('microsoft_calendar_client_secret')
if not client_id or not client_secret:
- raise UserError(_("The account for the Microsoft Calendar service is not configured."))
+ raise UserError(_("The account for the Outlook Calendar service is not configured."))
headers = {"content-type": "application/x-www-form-urlencoded"}
data = {
diff --git a/addons/microsoft_calendar/static/src/js/microsoft_calendar.js b/addons/microsoft_calendar/static/src/js/microsoft_calendar.js
index 41ad9e23675..289ba848b47 100644
--- a/addons/microsoft_calendar/static/src/js/microsoft_calendar.js
+++ b/addons/microsoft_calendar/static/src/js/microsoft_calendar.js
@@ -14,6 +14,23 @@ var _t = core._t;
const MicrosoftCalendarModel = CalendarModel.include({
+ /**
+ * @override
+ */
+ init: function () {
+ this._super.apply(this, arguments);
+ this.microsoft_is_sync = true;
+ },
+
+ /**
+ * @override
+ */
+ __get: function () {
+ var result = this._super.apply(this, arguments);
+ result.microsoft_is_sync = this.microsoft_is_sync;
+ return result;
+ },
+
/**
* @override
* @returns {Promise}
@@ -29,19 +46,27 @@ const MicrosoftCalendarModel = CalendarModel.include({
if (error.event) {
error.event.preventDefault();
}
- console.error("Could not synchronize Microsoft events now.", error);
+ console.error("Could not synchronize Outlook events now.", error);
}
return _super(...arguments);
},
_syncMicrosoftCalendar(shadow = false) {
+ var self = this;
return this._rpc({
route: '/microsoft_calendar/sync_data',
params: {
model: this.modelName,
fromurl: window.location.href,
}
- }, {shadow});
+ }, {shadow}).then(function (result) {
+ if (result.status === "need_config_from_admin" || result.status === "need_auth") {
+ self.microsoft_is_sync = false;
+ } else if (result.status === "no_new_event_from_microsoft" || result.status === "need_refresh") {
+ self.microsoft_is_sync = true;
+ }
+ return result
+ });
},
});
@@ -68,7 +93,7 @@ const MicrosoftCalendarController = CalendarController.include({
return this.model._syncMicrosoftCalendar().then(function (o) {
if (o.status === "need_auth") {
- Dialog.alert(self, _t("You will be redirected to Microsoft to authorize the access to your calendar."), {
+ Dialog.alert(self, _t("You will be redirected to Outlook to authorize the access to your calendar."), {
confirm_callback: function() {
framework.redirect(o.url);
},
@@ -76,14 +101,14 @@ const MicrosoftCalendarController = CalendarController.include({
});
} else if (o.status === "need_config_from_admin") {
if (!_.isUndefined(o.action) && parseInt(o.action)) {
- Dialog.confirm(self, _t("The Microsoft Synchronization needs to be configured before you can use it, do you want to do it now?"), {
+ Dialog.confirm(self, _t("The Outlook Synchronization needs to be configured before you can use it, do you want to do it now?"), {
confirm_callback: function() {
self.do_action(o.action);
},
title: _t('Configuration'),
});
} else {
- Dialog.alert(self, _t("An administrator needs to configure Microsoft Synchronization before you can use it!"), {
+ Dialog.alert(self, _t("An administrator needs to configure Outlook Synchronization before you can use it!"), {
title: _t('Configuration'),
});
}
@@ -104,7 +129,7 @@ const MicrosoftCalendarRenderer = CalendarRenderer.include({
//--------------------------------------------------------------------------
/**
- * Adds the Sync with Microsoft button in the sidebar
+ * Adds the Sync with Outlook button in the sidebar
*
* @private
*/
@@ -113,12 +138,16 @@ const MicrosoftCalendarRenderer = CalendarRenderer.include({
this._super.apply(this, arguments);
this.$microsoftButton = $();
if (this.model === "calendar.event") {
- this.$microsoftButton = $('', {type: 'button', html: _t("Sync with Microsoft")})
- .addClass('o_microsoft_sync_button oe_button btn btn-secondary')
- .prepend($('', {
- src: "/microsoft_calendar/static/src/img/calendar_outlook_32.png",
- }))
+ if (this.state.microsoft_is_sync) {
+ this.$microsoftButton = $('', {html: _t("Synched with Outlook")})
+ .addClass('o_microsoft_sync badge badge-pill badge-success')
+ .prepend($('', {class: "fa mr-2 fa-check"}))
.appendTo(self.$sidebar);
+ } else {
+ this.$microsoftButton = $('', {type: 'button', html: _t("Sync with Outlook")})
+ .addClass('o_microsoft_sync_button oe_button btn btn-secondary')
+ .appendTo(self.$sidebar);
+ }
}
},
diff --git a/addons/microsoft_calendar/static/src/scss/microsoft_calendar.scss b/addons/microsoft_calendar/static/src/scss/microsoft_calendar.scss
index b223bcdf965..2f1fa96bb6b 100644
--- a/addons/microsoft_calendar/static/src/scss/microsoft_calendar.scss
+++ b/addons/microsoft_calendar/static/src/scss/microsoft_calendar.scss
@@ -1,10 +1,12 @@
.o_microsoft_sync_button {
- display: block;
margin: auto;
> img {
margin-right: 10px;
}
}
+.o_microsoft_sync.badge {
+ border: none;
+}
img.calendar_img_tuto {
margin: 0 0 10px 50px;
diff --git a/addons/microsoft_calendar/wizard/reset_account_views.xml b/addons/microsoft_calendar/wizard/reset_account_views.xml
index 0fb789fe701..1646c6e9db4 100644
--- a/addons/microsoft_calendar/wizard/reset_account_views.xml
+++ b/addons/microsoft_calendar/wizard/reset_account_views.xml
@@ -5,7 +5,7 @@
microsoft.calendar.account.reset