# HG changeset patch # User Vincent Hatakeyama <vincent.hatakeyama@xcg-consulting.fr> # Date 1616666322 -3600 # Thu Mar 25 10:58:42 2021 +0100 # Node ID 8be72e2a76dfc3fd7024834102056272e5014cef # Parent ef395bd8a09a5abb0092f40453be253305cd146d 🚑 Fix reading odoo_type when using expansion. diff --git a/NEWS.rst b/NEWS.rst --- a/NEWS.rst +++ b/NEWS.rst @@ -13,6 +13,8 @@ Fix reading configuration value in python 2.7. +Fix reading odoo_type when using expansion. + 7.0.3 ----- diff --git a/odoo_scripts/config.py b/odoo_scripts/config.py --- a/odoo_scripts/config.py +++ b/odoo_scripts/config.py @@ -64,7 +64,9 @@ if blacklist and re.match(blacklist, value["path"]): _logger.info( "Ignoring directory '%s' due to blacklisting", - value["path"], + os.path.join(path, value["path"]) + if path + else value["path"], ) else: if path: @@ -125,9 +127,7 @@ for key in ("db_user", "db_password", "load-language"): setattr(self, key_format(key), section.get(key, None)) - def read_expanded( - key: str, default_value=None, always_set: bool = False - ): + def read_expanded(key: str, default_value=None): """Read from local version, or from expanded if value is found. Raise an exception if more than one value is found.""" value = default_value @@ -155,22 +155,33 @@ " with different values" % key ) value = local_value - if toread(key) or always_set: + if toread(key): setattr(self, key, value) self.registry = section.get("registry", "registry.xcg.io") project_path = os.path.realpath(".") self.image = section.get("image", os.path.basename(project_path)) - read_expanded("odoo_type", "odoo7", always_set=True) - if self.odoo_type not in ( + read_expanded("odoo_type", "odoo7") + if not hasattr(self, "odoo_type"): + # if path is set, odoo_type might not be in the values to read + # so no message + if not path: + _logger.warning("Missing odoo_type") + elif self.odoo_type not in ( "odoo7", "odoo8", "odoo10", "odoo11", "odoo13", ): - _logger.warning("Unexpected odoo_type: %s", self.odoo_type) - read_expanded("postgresql_version", "9.6") + if path: + _logger.info( + "Unexpected odoo_type: %s in %s", + (self.odoo_type, self.path), + ) + else: + _logger.warning("Unexpected odoo_type: %s", self.odoo_type) + read_expanded("postgresql_version", "9.6") self.start_py3o = section.get("start_py3o", "no") in ("yes", "true")