def uninstall(
    c,
    modules=None,
    cur_file=None,
):
    """Uninstall Odoo addons

    By default, uninstalls addon from directory being worked on,
    unless other options are specified.
    """
    if not modules:
        cur_module = _get_cwd_addon(cur_file or Path.cwd())
        if not cur_module:
            raise exceptions.ParseError(
                msg="Odoo addon to uninstall not found. "
                "You must provide at least one option for modules"
                " or be in a subdirectory of one."
                " See --help for details.")
        modules = cur_module
    cmd = (
        f"docker-compose run --rm odoo click-odoo-uninstall -m {modules or cur_module}"
    )
    with c.cd(str(PROJECT_ROOT)):
        c.run(
            cmd,
            env=UID_ENV,
            pty=True,
        )
Пример #2
0
def install(c, modules=None, core=False, extra=False, private=False):
    """Install Odoo addons

    By default, installs addon from directory being worked on,
    unless other options are specified.
    """
    if not (modules or core or extra or private):
        cur_module = _get_cwd_addon(Path.cwd())
        if not cur_module:
            raise exceptions.ParseError(
                msg="Odoo addon to install not found. "
                "You must provide at least one option for modules"
                " or be in a subdirectory of one."
                " See --help for details."
            )
        modules = cur_module
    cmd = "docker-compose run --rm odoo addons init"
    if core:
        cmd += " --core"
    if extra:
        cmd += " --extra"
    if private:
        cmd += " --private"
    if modules:
        cmd += f" -w {modules}"
    with c.cd(str(PROJECT_ROOT)):
        c.run(
            cmd,
            env=UID_ENV,
            pty=True,
        )
Пример #3
0
def test(c, modules=None, debugpy=False, cur_file=None, mode="init"):
    """Run Odoo tests

    By default, tests addon from directory being worked on,
    unless other options are specified.

    NOTE: Odoo must be restarted manually after this to go back to normal mode
    """
    if not modules:
        cur_module = _get_cwd_addon(cur_file or Path.cwd())
        if not cur_module:
            raise exceptions.ParseError(
                msg="Odoo addon to test not found. "
                "You must provide at least one option for modules/file "
                "or be in a subdirectory of one. "
                "See --help for details.")
        else:
            modules = cur_module
    odoo_command = [
        "odoo", "--test-enable", "--stop-after-init", "--workers=0"
    ]
    if mode == "init":
        odoo_command.append("-i")
    elif mode == "update":
        odoo_command.append("-u")
    else:
        raise exceptions.ParseError(
            msg=
            "Available modes are 'init' or 'update'. See --help for details.")
    odoo_command.append(modules)
    if debugpy:
        _test_in_debug_mode(c, odoo_command)
    else:
        cmd = ["docker-compose", "run", "--rm", "odoo"]
        cmd.extend(odoo_command)
        with c.cd(str(PROJECT_ROOT)):
            c.run(
                " ".join(cmd),
                env=UID_ENV,
                pty=True,
            )
Пример #4
0
def test(
    c,
    modules=None,
    core=False,
    extra=False,
    private=False,
    enterprise=False,
    skip="",
    debugpy=False,
    cur_file=None,
    mode="init",
    db_filter="^devel$",
):
    """Run Odoo tests

    By default, tests addon from directory being worked on,
    unless other options are specified.

    NOTE: Odoo must be restarted manually after this to go back to normal mode
    """
    if not (modules or core or extra or private or enterprise):
        cur_module = _get_cwd_addon(cur_file or Path.cwd())
        if not cur_module:
            raise exceptions.ParseError(
                msg="Odoo addon to install not found. "
                "You must provide at least one option for modules"
                " or be in a subdirectory of one."
                " See --help for details.")
        modules = cur_module
    else:
        modules = _get_module_list(c, modules, core, extra, private,
                                   enterprise)
    odoo_command = [
        "odoo", "--test-enable", "--stop-after-init", "--workers=0"
    ]
    if mode == "init":
        odoo_command.append("-i")
    elif mode == "update":
        odoo_command.append("-u")
    else:
        raise exceptions.ParseError(
            msg=
            "Available modes are 'init' or 'update'. See --help for details.")
    # Skip test in some modules
    modules_list = modules.split(",")
    for m_to_skip in skip.split(","):
        if not m_to_skip:
            continue
        if m_to_skip not in modules:
            _logger.warn("%s not found in the list of addons to test: %s" %
                         (m_to_skip, modules))
        modules_list.remove(m_to_skip)
    modules = ",".join(modules_list)
    odoo_command.append(modules)
    if ODOO_VERSION >= 12:
        # Limit tests to explicit list
        # Filter spec format (comma-separated)
        # [-][tag][/module][:class][.method]
        odoo_command.extend(["--test-tags", "/" + ",/".join(modules_list)])
    if debugpy:
        _test_in_debug_mode(c, odoo_command)
    else:
        cmd = ["docker-compose", "run", "--rm"]
        if db_filter:
            cmd.extend(["-e", "DB_FILTER='%s'" % db_filter])
        cmd.append("odoo")
        cmd.extend(odoo_command)
        with c.cd(str(PROJECT_ROOT)):
            c.run(
                " ".join(cmd),
                env=UID_ENV,
                pty=True,
            )