[FIX] microsoft_calendar: avoid deadlock at token refresh
We should rollback manually first to avoid concurrent access errors/deadlocks when trying to refresh microsoft calendar token. opw-2630601 closes odoo/odoo#77955 X-original-commit: 5cd27e3440efae06bee6a96aee39f4d2c509ede7 Signed-off-by: Arnaud Joset <arj-odoo@users.noreply.github.com> Signed-off-by: Alex Tuyls <alt-odoo@users.noreply.github.com>
This commit is contained in:
@@ -66,13 +66,14 @@ class User(models.Model):
|
||||
'microsoft_calendar_token_validity': fields.Datetime.now() + timedelta(seconds=ttl),
|
||||
})
|
||||
except requests.HTTPError as error:
|
||||
if error.response.status_code in (400, 401): # invalid grant
|
||||
if error.response.status_code in (400, 401): # invalid grant or invalid client
|
||||
# Delete refresh token and make sure it's commited
|
||||
self.env.cr.rollback()
|
||||
self.write({
|
||||
'microsoft_calendar_rtoken': False,
|
||||
'microsoft_calendar_token': False,
|
||||
'microsoft_calendar_token_validity': False,
|
||||
'microsoft_calendar_sync_token': False,
|
||||
})
|
||||
self.env.cr.commit()
|
||||
error_key = error.response.json().get("error", "nc")
|
||||
|
||||
Reference in New Issue
Block a user