Skip to content

Features

Viet Dinh edited this page May 18, 2024 · 48 revisions

A more complete listing is also available in the Support Matrix.

Legend

  • 🐍 Python
  • πŸ“ XML
  • β˜• JavaScript
  • 🌟 Specific to odoo-lsp

CLI commands

  • odoo-lsp init generates an .odoo_lsp config file for the LSP
  • odoo-lsp tsconfig generates a tsconfig.json prefilled with paths to legacy modules
  • odoo-lsp self-update to update the binary
    Also recommended to add --nightly flag while the LSP is still under heavy development

Completion, definition and references for XML records

  • 🐍 *.env.ref()
  • 🐍 request.render()
  • πŸ“ inherit_id=
  • πŸ“ id= (references only)
  • πŸ“ ref=
  • πŸ“ <menuitem parent=".." />

inherit_id demo

🌟 Model annotations

odoo-lsp offers a non-standard syntax to annotate the model of a binding in XML:

<template>
  <!-- @type foo stock.picking -->
  <t t-out="foo.|"/>
  <!--          ^
                fields of stock.picking should appear here -->
</template>

Completion, definition and references for QWeb templates

  • πŸ“ t-inherit=, t-call=
    • No usage references yet
  • πŸ“ <Component prop=".." />
  • β˜• static template=

Completion, definition and references for models

  • 🐍 *.env[]
  • 🐍 _inherit=
  • 🐍 comodel_name for relational fields
  • 🐍 _name= (references only)

model demo

Completion and definition for model fields

  • πŸ“ name=
  • 🐍 Model.field
  • 🐍 Mapped access (completions, hover)
    • fields.*(related='..')
    • @api.{depends,constrains}('..')
    • Model.{mapped,sorted,create,write..}(..)
    • Fields in domains (for search, read_group etc.)

field demo

Code actions

πŸ“ Jump to Owl component definition

goto_owl.webm

Browse records and models 🐍 πŸ“

  • VSCode: Ctrl + T, or Quick Open Ctrl + P and prefix with #
  • Helix: Space then Shift + S in normal mode

By default, records and models are matched by prefix, unless when the query contains a period in which case it will be parsed as a module-scoped query. For example base.view_ searches for:

  • all records whose id starts with view_ and defined in the base module; and
  • all models whose _name starts with view_

symbols demo

Diagnostics

  • 🐍 Non-existent fields, XML records
  • 🐍 Invalid dotted access

VS Code extension features

Syntax enhancements

Language injections for Python, JavaScript and XPath expressions in XML attributes.

  • 🐍 t-* and other attributes
  • β˜• t-on-click*
  • πŸ“ <xpath expr=".." /> (requires the XSLT/XPath extension)
xml_syntax_highlight.mp4

Odoo XML completions and diagnostics

Schema sourced from the official XML validator used by Odoo. Supports <record>, <field>, <menuitem> and many other structures. Powered by the XML extension.

xml_schema.mp4