diff --git a/djangodoo/__init__.py b/djangodoo/__init__.py index 124062f..83356f4 100644 --- a/djangodoo/__init__.py +++ b/djangodoo/__init__.py @@ -2,6 +2,7 @@ from django.conf import settings from django.db.models.signals import class_prepared from django.core.mail import send_mail + import erppeek from .fields import convert_field import logging @@ -10,6 +11,7 @@ import traceback logger = logging.getLogger(__name__) +VERSION = "0.3.0" def set_auth_cache(): @@ -21,7 +23,12 @@ def set_auth_cache(): def set_odoo_client(): config = getattr(settings, "ODOO_HOST", False) - logger.info("Setting up the Odoo client...") + if not config: + raise RuntimeError("You need to define ODOO_HOST in your settings in order to use Djangodoo.") + elif not config.get("HOST", None): + raise RuntimeError("You need to provide a HOST location in ODOO_HOST in order to use Djangodoo.") + + logger.info("Setting up the Odoo client (djangodoo version {})...".format(VERSION)) max_retry_attempts = getattr(settings, "ODOO_MAX_RETRY_ATTEMPTS", 3) retry_delay = getattr(settings, "ODOO_RETRY_DELAY", 5) @@ -44,11 +51,11 @@ def _connect(retry_cnt): logger.error('Unable to connect to a running Odoo server. Aborting.') mail_config = getattr(settings, "ODOO_EMAIL_NOTIFICATION", False) mail_content = """Unable to connect to a running Odoo server. Your application may have failed to start up due to a connection problem with an Odoo instance. - + Djangodoo tried to reconnect {} times, waiting {} seconds between each attempt. Still, the server could not be reached. The problem occured with the following host configuration: - + USER: {} HOST: {} PORT: {} @@ -58,14 +65,15 @@ def _connect(retry_cnt): {} - + + """.format(max_retry_attempts, retry_delay, config['USER'], config['HOST'], config['PORT'], config['DB'], traceback.format_exc()) html_content = """
Unable to connect to a running Odoo server. Your application may have failed to start up due to a connection problem with an Odoo instance.
- +Djangodoo tried to reconnect {} times, waiting {} seconds between each attempt. Still, the server could not be reached.
The problem occured with the following host configuration:
- +