CodeLens provides contextual actions directly in the editor, showing useful links above relevant classes and methods.
CodeLens automatically appears above:
When you open a Python file with Odoo models, youβll see links above each class:
class SaleOrder(models.Model): # β [Create Views] [Create Report] [Import Security]
_name = 'sale.order'
_description = 'Sales Order'
| Action | Description | Alternative Command |
|---|---|---|
| Create Views | Generates XML file with views | Odoo Shortcuts: Create Views |
| Create Report | Generates QWeb report | Odoo Shortcuts: New Report |
| Import Security | Creates access rules | Odoo Shortcuts: Import Security Model Access |
| Create Inherit View | Generates inherited views | Odoo Shortcuts: Create Inherit Views |
For OWL components, CodeLens shows:
/** @odoo-module **/
export class MyComponent extends Component { // β [OWL Documentation]
static template = "my_module.MyComponent";
}
| Action | Description |
|---|---|
| OWL Documentation | Opens OWL documentation in webview |
{
"odooFile.codelens.enabled": true // or false to disable
}
CodeLens automatically activates for:
.py).js).ts)
# Open models/sale_order.py
class SaleOrder(models.Model):
# [Create Views] [Create Report] [Import Security] β Appears here
_name = 'sale.order'
_description = 'Sales Order'
name = fields.Char(string='Name')
partner_id = fields.Many2one('res.partner', string='Customer')
You click [Create Views]:
views/sale_order_views.xml__manifest__.pyCodeLens appears as light gray text above definitions:

[Create Views] [Create Report] [Import Security]
class MyModel(models.Model):
Color and style follow the VS Code theme.
odooFile.codelens.enabled is trueCodeLens uses heuristics to detect Odoo models:
models.Model in codeIf CodeLens slows down the editor:
"odooFile.codelens.enabled": falseCodeLens is the fastest way to generate code related to a model.
Links only appear when relevant, keeping the editor clean.
If a file has multiple models, each will have its own CodeLens links.
| Feature | CodeLens | Commands |
|---|---|---|
| Speed | One click | Command palette |
| Context | Model specific | General |
| Discovery | Automatic visual | Memorize shortcuts |
| Flexibility | Current model | Any model |
Recommendation: Use CodeLens for the current model, commands for other models.
CodeLens works through:
Analysis is done in real-time as you edit.
Next: XPath Tools