Skip to content
Snippets Groups Projects
Commit 1e0e4e8a authored by pedrambiria's avatar pedrambiria Committed by Pedram (PEBR)
Browse files

[FIX] microsoft_calendar: keep sync_stopped status


Before this commit, if you stopped sync with microsoft, and
refereshed the calendar, it would change the button back to
synced status.

opw-3382311

closes odoo/odoo#126077

Signed-off-by: default avatarArnaud Joset (arj) <arj@odoo.com>
parent c8fdceab
No related branches found
No related tags found
No related merge requests found
......@@ -41,6 +41,13 @@ class MicrosoftCalendarController(http.Controller):
}
# If App authorized, and user access accepted, We launch the synchronization
need_refresh = request.env.user.sudo()._sync_microsoft_calendar()
# If synchronization has been stopped
if not need_refresh and request.env.user.microsoft_synchronization_stopped:
return {
"status": "sync_stopped",
"url": ''
}
return {
"status": "need_refresh" if need_refresh else "no_new_event_from_microsoft",
"url": ''
......
......@@ -6,6 +6,9 @@ from odoo.addons.microsoft_calendar.utils.microsoft_event import MicrosoftEvent
from odoo.addons.microsoft_calendar.models.res_users import User
from odoo.addons.microsoft_calendar.utils.event_id_storage import combine_ids
from odoo.addons.microsoft_calendar.tests.common import TestCommon, mock_get_token, _modified_date_in_the_future, patch_api
from odoo.tests import users
import json
@patch.object(User, '_get_microsoft_calendar_token', mock_get_token)
......@@ -154,3 +157,26 @@ class TestAnswerEvents(TestCommon):
('partner_id', '=', self.attendee_user.partner_id.id)
])
self.assertEqual(attendee.state, "declined")
@users('admin')
def test_sync_data_with_stopped_sync(self):
self.authenticate(self.env.user.login, self.env.user.login)
self.env['ir.config_parameter'].sudo().set_param(
'microsoft_calendar_client_id',
'test_microsoft_calendar_client_id'
)
self.env.user.sudo().microsoft_calendar_rtoken = 'test_microsoft_calendar_rtoken'
self.env.user.stop_microsoft_synchronization()
payload = {
'params': {
'model': 'calendar.event'
}
}
# Sending the request to the sync_data
response = self.url_open(
'/microsoft_calendar/sync_data',
data=json.dumps(payload),
headers={'Content-Type': 'application/json'}
).json()
# the status must be sync_stopped
self.assertEqual(response['result']['status'], 'sync_stopped')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment