From 800cc260ed3691f37a2ccf5a8ec725dab5ed8065 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Thu, 10 May 2018 17:37:15 +0200 Subject: [PATCH] [REM][WIP]Radicale Odoo Storage : remove unused global admin connection --- radicale_odoo_storage/__init__.py | 48 ------------------------------- 1 file changed, 48 deletions(-) diff --git a/radicale_odoo_storage/__init__.py b/radicale_odoo_storage/__init__.py index 94b396c..8ae4223 100644 --- a/radicale_odoo_storage/__init__.py +++ b/radicale_odoo_storage/__init__.py @@ -49,8 +49,6 @@ class Collection(BaseCollection): if not self.__class__.odoo: self.logger.error('No auth Odoo found...') raise RuntimeError('No auth Odoo found') - # self.__class__.odoo_connect() - # self.odoo_init() odoo_timezone = self.configuration.get('storage', 'odoo_timezone') self.__class__.server_timezone = pytz.timezone(odoo_timezone) @@ -76,52 +74,6 @@ class Collection(BaseCollection): self.owner = attributes[0] self.is_principal = len(attributes) == 0 - @classmethod - def odoo_connect(cls): - """ Global Odoo connection : server and admin account """ - host = cls.configuration.get('storage', 'odoo_host', fallback='127.0.0.1') - port = cls.configuration.get('storage', 'odoo_port', fallback=8069) - admin = cls.configuration.get('storage', 'odoo_admin_username') - password = cls.configuration.get('storage', 'odoo_admin_password') - database = cls.configuration.get('storage', 'odoo_database') - try: - cls.odoo = ODOO(host, port=port) - except RPCError as rpcerr: - cls.logger.error(rpcerr) - raise RuntimeError(rpcerr) - try: - cls.odoo.login(database, admin, password) - cls.logger.info('Login successfull for {} on database {}'.format(admin, database)) - except RPCError as rpcerr: - cls.logger.error('Login problem for {} on database {}'.format(cls, database)) - cls.logger.error(rpcerr) - raise RuntimeError(rpcerr) - return True - - def odoo_init(self): - """ Init Odoo collections if not found """ - user_ids = self.odoo.env['res.users'].search([]) - users = self.odoo.execute('res.users', 'read', user_ids, ['login', 'email']) - for user in users: - principal_path = user.get('login') - self.logger.debug('Check collections from Odoo for %s' % principal_path) - contact_path = '%s/odoo-contact' % principal_path - calendar_path = '%s/odoo-calendar' % principal_path - collections = self.discover(principal_path, depth='1') - paths = [coll.path for coll in collections] - if contact_path not in paths: - props = {'tag': 'VADDRESSBOOK', - 'D:displayname': 'Odoo contacts', - 'C:calendar-description': 'Contacts form your Odoo account'} - self.create_collection(contact_path, props=props) - self.logger.info('Collection creation for Odoo Sync : %s' % contact_path) - if calendar_path not in paths: - props = {'tag': 'VCALENDAR', - 'D:displayname': 'Odoo calendar', - 'C:calendar-description': 'Events form your Odoo calendar'} - self.create_collection(calendar_path, props=props) - self.logger.info('Collection creation for Odoo Sync : %s' % calendar_path) - @classmethod def odoo_date_to_utc(cls, date_obj): """ Transform naive Odoo date object to UTC TZ """