Smart suggestions
Get completions for models, fields, methods, XML IDs, widgets, templates and CSS classes as you type. Suggestions follow your Odoo version, and the names come from an index of your workspace, including Odoo's own source when it is in the workspace.
What you can do
Items marked index need the background index to finish.
Python
| You type | You get |
|---|---|
fields. | Field classes of your version (Char, Many2one, Properties, ...), inserted as Char(string="..."). |
= inside a fields.X(...) call | Field parameters valid for your version (string, required, compute, ondelete, tracking, ...). |
@ | api. decorators of your version. |
fields.Many2one(', One2many, Many2many, comodel_name=' | Model names. index |
_inherit = ' (string, list or tuple) | Model names. index |
self.env[' | Model names. index |
fields.One2many('model', ' or inverse_name=' | The Many2one fields of that model that point back to the current model. index |
self. and record. inside for record in ... | Fields of the current model, continuing through relations (self.partner_id. gives fields of res.partner). index |
@api.depends(' and @api.onchange(' | Fields of the current model. index |
def _compute_, def _inverse_, def _search_ | Field names of the current class, to complete the method name. |
def in a class with _inherit | Methods of the inherited model. Choosing one inserts the override with a super() call. index |
odoo ... | All Odoo snippets, including import snippets such as odoo common imports, odoo import http request and odoo import logging. |
XML
| Where the cursor is | You get |
|---|---|
< | Tags of your version: data tags (record, field, menuitem, template), every view type (form, list, kanban, search, calendar, graph, pivot, activity, hierarchy, and card on Odoo 20), view elements and QWeb t. |
| Inside a tag | Only the attributes that tag accepts in your version, taken from Odoo's own schemas and core views. For example, card_id and dialog_size on Odoo 20 and date_delay on 18 and 19. |
<field name=" or <filter name=" in a view | Fields of the view's model. index |
<button name=" with type="object" | Methods of the view's model. index |
<record model=", and the text of <field name="model"> or <field name="res_model"> | Model names. index |
Text of <field name="view_mode"> | list, form, kanban, pivot, graph, calendar, activity, hierarchy. |
Text of <field name="tag"> in an ir.actions.client record | Client action tags registered in JavaScript. index |
widget=" on a field | Field widgets registered in JavaScript, with their module. index |
t-call=" | QWeb template IDs. index |
t-component=" or <owl-component name=" | Public components. index |
position=" on <xpath> | after, before, inside, replace, attributes. |
class=" | CSS classes, ordered: current module, then web, base, mail, portal, then the rest. index |
odoo ... | All XML snippets. |
Manifest
In __manifest__.py:
depends: module names from your workspace when you open a quote on a line that containsdepends. indexdata,demoandassetspaths: the module's files and folders as you type. Asset paths start with the module name, as Odoo expects.
What a suggestion shows
Each suggestion carries a short label next to it.
| Suggestion | Label |
|---|---|
| Field of a model (Python) | Type: Many2one → res.partner (the type, and the related model for relational fields) |
| Field of a model (XML) | The field type and its module, such as Many2one (sale) |
| Inherited method | Inherited from sale.order (sale) |
| Widget or public component | Module: <module name> |
| CSS class | Odoo Core: web or Module: <module name> |
position value | Odoo Xpath Position |
Follow relations
Type self. or record. and a field name, then a dot, to complete the fields of the related model. The completion continues through each relation you type.
class SaleOrder(models.Model):
_inherit = 'sale.order'
def action_check(self):
self.ensure_one()
self.partner_id. # fields of res.partner
self.order_line. # fields of sale.order.lineA loop variable works the same way. After for line in self.order_line:, typing line. suggests the fields of sale.order.line. If a name in the chain is not a relational field, the suggestions stop there.
Get started
- Open a folder that contains Odoo modules and wait a few seconds for the index.
- Start typing in a
.pyor.xmlfile. Suggestions appear automatically. - Add the Odoo source folder to your workspace to get core models, fields and templates too.
To open the list by hand, press Ctrl+Space. Press Tab or Enter to accept a suggestion and Esc to dismiss the list.
Tips and limits
- Python suggestions take the current model from the first
_name(or_inherit) in the file. Keep one model per file for accurate results. - Python field completion inside decorators works for
@api.dependsand@api.onchange. - Inside an
<xpath>of an inherited view, field suggestions use the view record rather than the inherited view's model. dependssuggestions appear on lines that contain the worddepends.- Large workspaces can turn off parts of the index in the settings.