Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
David Arnold committed Dec 10, 2019
1 parent a4b21cf commit 2f5bf66
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 67 deletions.
8 changes: 5 additions & 3 deletions dodoo/dodoo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def framework():
return _framework


def main(framework_dir, config_dir, call_home, run_mode, log_level, codeversion_file):
def main(
framework_dir, config_dir, call_home, run_mode, log_level, projectversion_file
):
"""Provide the common cli entrypoint, initialize the dodoo python
environment, load configuration and set up logging.
Expand All @@ -70,15 +72,15 @@ def main(framework_dir, config_dir, call_home, run_mode, log_level, codeversion_

# Load odoo module from specified framework path
if framework_dir:
sys.path.insert(0, framework_dir)
sys.path.insert(0, str(framework_dir))

# Hold a reference to the global odoo namespace so it's not
# garbage collected after beeing patched
global _framework
import odoo as _framework

_framework.dodoo_run_mode = run_mode
_framework.dodoo_project_version = codeversion_file.read().rstrip()
_framework.dodoo_project_version = projectversion_file.read().rstrip()

odoo.Tools.resetlocale()

Expand Down
2 changes: 1 addition & 1 deletion dodoo/dodoo/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
help="Specify the log level from: info, debug. Without: warn.",
)
@click.argument(
"codeversion-file",
"projectversion-file",
type=click.File("r"),
# help="Specify the version file containing the project's semantic version",
)
Expand Down
54 changes: 31 additions & 23 deletions dodoo/dodoo/interfaces/odoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ class Authentication:
def authenticate(database, login, password, context=None):
if not context:
context = {}
return import_module("odoo.service.common.exp_authenticate")(
database, login, password, context
)
common = import_module("odoo.service.common")
return common.exp_authenticate(database, login, password, context)


class WSGI:
Expand All @@ -36,79 +35,88 @@ def app(self):

class Registry:
def __new__(cls, dbname):
return import_module("odoo.modules.registry.Regsitry")(dbname)
registry = import_module("odoo.modules.registry")
return registry.Regsitry(dbname)

@staticmethod
def items():
return import_module("odoo.modules.registry.Regsitry.registries").items()
registry = import_module("odoo.modules.registry")
return registry.Regsitry.registries.items()


class Environment:
def __new__(cls, cr, uid, context=None):
if not context:
context = {}
manage_environments = import_module("odoo.api.Environment.manage")
with manage_environments():
yield import_module("odoo.api.Environment")(cr, uid, context)
Environment = import_module("odoo.api.Environment")
with Environment.manage():
yield Environment(cr, uid, context)


class Cron:
@staticmethod
def acquire(dbname):
return import_module("odoo.addons.base.models.ir_cron.ir_cron._acquire_job")(
dbname
)
ir_cron = import_module("odoo.addons.base.models.ir_cron")
return ir_cron.ir_cron._acquire_job(dbname)


class Tools:
@staticmethod
def resetlocale():
import_module("odoo.tools.translate.resetlocale")()
tools = import_module("odoo.tools")
tools.resetlocale()

@staticmethod
def lazy(obj):
import_module("odoo.tools.func.lazy")(obj)
func = import_module("odoo.tools.func")
func.lazy(obj)


class Modules:
@staticmethod
def initialize_sys_path():
import_module("odoo.modules.module.initialize_sys_path")()
module = import_module("odoo.modules.module")
module.initialize_sys_path()

@property
def MANIFEST_NAMES(self):
return import_module("odoo.modules.module.MANIFEST_NAMES")
module = import_module("odoo.modules.module")
return module.MANIFEST_NAMES

@property
def loaded(self):
return import_module("odoo.modules.module.MANIFEST_NAMES")
module = import_module("odoo.modules.module")
return module.loaded

@property
def load(self, module):
return import_module("odoo.modules.module.load_openerp_module")(module)
module = import_module("odoo.modules.module")
return module.load_openerp_module(module)

@property
def deduce_module_name_from(self, path):
return import_module("odoo.modules.module.get_module_root")(path)
module = import_module("odoo.modules.module")
return module.get_module_root(path)

@property
def deduce_module_and_relpath_from(self, path):
res = import_module("odoo.modules.module.get_resource_from_path")(path)
module = import_module("odoo.modules.module")
res = module.get_resource_from_path(path)
if not res: # Fixing the return signature
return None, None
return res

@property
def parse_manifest_from(self, module):
return import_module(
"odoo.modules.module.load_information_from_description_file"
)(module)
module = import_module("odoo.modules.module")
return module.load_information_from_description_file(module)


class Database:
@staticmethod
def close_all():
import_module("odoo.sql_db.close_all")()
sql_db = import_module("odoo.sql_db")
sql_db.close_all()


class Config:
Expand Down
Loading

0 comments on commit 2f5bf66

Please sign in to comment.