summaryrefslogtreecommitdiff
path: root/addons/google_calendar/models/google_sync.py
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2020-03-25 14:21:50 +0100
committerLucas Lefèvre <lul@odoo.com>2020-04-09 10:59:34 +0200
commit1a9be3a8699df6422b4e1fe2d91cbbec48fae9de (patch)
treee703f821c33fd33473e65f7c61640f4e2acf52e0 /addons/google_calendar/models/google_sync.py
parentf2b69186499f7288af6d129986ad3d9d92b010c6 (diff)
[REF] calendar: Lint + Clean code
Diffstat (limited to 'addons/google_calendar/models/google_sync.py')
-rw-r--r--addons/google_calendar/models/google_sync.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/addons/google_calendar/models/google_sync.py b/addons/google_calendar/models/google_sync.py
index bf8ab27e454..377aaac6a61 100644
--- a/addons/google_calendar/models/google_sync.py
+++ b/addons/google_calendar/models/google_sync.py
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
import logging
+from contextlib import contextmanager
+from functools import wraps
import requests
import pytz
-from functools import wraps
from dateutil.parser import parse
-from contextlib import contextmanager
from odoo import api, fields, models, registry, _
from odoo.tools import ormcache_context
@@ -52,7 +53,7 @@ def google_calendar_token(user):
# Rollback manually first to avoid concurrent access errors/deadlocks.
user.env.cr.rollback()
with user.pool.cursor() as cr:
- env= user.env(cr=cr)
+ env = user.env(cr=cr)
user.with_env(env)._set_auth_tokens(False, False, 0)
raise e
@@ -155,7 +156,7 @@ class GoogleSync(models.AbstractModel):
cancelled_odoo._cancel()
synced_records = new_odoo + cancelled_odoo
- for gevent in existing - cancelled :
+ for gevent in existing - cancelled:
# Last updated wins.
# This could be dangerous if google server time and odoo server time are different
updated = parse(gevent.updated)
@@ -169,7 +170,6 @@ class GoogleSync(models.AbstractModel):
@after_commit
def _google_delete(self, google_service: GoogleCalendarService, google_id, timeout=TIMEOUT):
- print('DELETE', google_id)
with google_calendar_token(self.env.user.sudo()) as token:
if token:
google_service.delete(google_id, token=token, timeout=timeout)
@@ -177,7 +177,6 @@ class GoogleSync(models.AbstractModel):
@after_commit
def _google_patch(self, google_service: GoogleCalendarService, google_id, values, timeout=TIMEOUT):
- print('Patch', google_id)
with google_calendar_token(self.env.user.sudo()) as token:
if token:
google_service.patch(google_id, values, token=token, timeout=timeout)
@@ -185,7 +184,6 @@ class GoogleSync(models.AbstractModel):
@after_commit
def _google_insert(self, google_service: GoogleCalendarService, values, timeout=TIMEOUT):
- print('insert')
if not values:
return
with google_calendar_token(self.env.user.sudo()) as token: