Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions odoo_tools/tasks/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from invoke import task

from ..utils import db, ui


def get_addons_path():
"""Reconstruct addons_path based on known odoo module locations"""
Expand Down Expand Up @@ -59,8 +61,26 @@ def get_dependencies(self):
with open(manifest_path) as f:
return eval(f.read()).get("depends", [])

@classmethod
def get_installed_addons(cls, dbname="odoodb"):
query = "SELECT name FROM ir_module_module WHERE state = 'installed';"
result = db.execute_db_request(dbname, query)
return [mod_name for [mod_name] in result]


@task
def where_is(ctx, module_name):
"""Locate a module"""
print(Module(module_name).path)


@task
def installed(ctx, db_name="odoodb"):
"""List installed addons."""
db_list = db.get_db_list()
if db_name not in db_list:
ui.exit_msg(
f"Database {db_name} does not exist.\nAvailable: {', '.join(db_list)}"
)
res = Module.get_installed_addons(dbname=db_name)
print("\n".join(sorted(res)))