Skip to content
Viet Dinh edited this page Dec 2, 2023 · 8 revisions

Welcome to the odoo-lsp wiki! Check out the pages on the sidebar to learn more about how to use odoo-lsp and its various features.

Usage

odoo-lsp operates based on a concepts of roots and allows strict management of which roots to include. In short, they are similar to the arguments passed to --addons-path when starting an Odoo server. By default, when starting an editing session the only root is the working directory, and you can configure this per directory by placing an .odoo_lsp JSON configuration file at the directory from which you launch your editor.

Note

If you're using VSCode multi-root workspaces, they have the same effect as manually specifying addon roots in .odoo_lsp.

// A sample configuration file
{
  "module": {
    "roots": [
      "/path/to/modules", // absolute paths
      "./foo",            // or relative paths
      "partner/addon-*",  // or globbed paths all work
    ]
  }
}

For example, for this given configuration:

.
.odoo_lsp
foo/
  one/__manifest__.py
  two/__manifest__.py
  three/__manifest__.py
16/
  odoo/addons/
15/
  odoo/addons/

If one wants to only load foo and 16, the necessary configuration for .odoo_lsp is as follows:

{
  "module": {
    "roots": ["16", "foo"]
  }
}

This avoids loading 15 as a root and prevents issues with code completion. You can also run this command to generate the same config file:

# Optionally add --tsconfig to generate a tsconfig.json ready to be used by Typescript
odoo-lsp init --addons-path 16,foo --tsconfig

Philosophy

  • Rely maximally on the source code, not the database
  • Make it easier to adapt to new editors and situations

Prior Art

Clone this wiki locally