---
url: https://docs.cybrosys.com/assista-ide/odoo-standards/code-suggestion.md
description: >-
  Get Odoo-aware completions and go-to-definition in Python, XML and manifest
  files, based on your own project and your Odoo version.
---

# Context-aware suggestions

As you type, Assista IDE suggests the model, field, method and template names that exist in your project, and lets you jump to their definitions. The suggestions come from an index of your workspace and follow your Odoo version, so you make fewer typos and spend less time searching.

These features come from the bundled Odoo Helper and support Odoo 18, 19 and 20.

## What you can do

* **Complete names from your project**: models, fields, methods, XML IDs, templates, widgets and CSS classes.
* **Follow relations**: after `self.partner_id.` you get the fields of `res.partner`.
* **Jump to definitions** from XML to Python and between Python files.
* **Complete manifest paths** for `depends`, `data`, `demo` and `assets`.
* **Get version-correct tags and attributes** in XML.
* **Override inherited methods** with a `super()` call already in place.

## Get started

1. Open a folder that contains Odoo modules. Suggestions are active when the workspace has a `__manifest__.py` or an `odoo/release.py`.
2. Wait a few seconds after the window opens. The workspace is indexed in the background, and suggestions that depend on the index appear when it is ready. Indexing shows no progress bar. Later opens reuse the saved index and only read changed files.
3. Start typing. Suggestions appear on their own. Press `Ctrl+Space` to open them again, `Tab` or `Enter` to accept one and `Esc` to close the list.

Check the Odoo version in the status bar, for example `Odoo v20 (Auto)`. Select it to change the version. See [Create modules and files](/assista-ide/module-creation).

> **Tip.**
>
> Add the Odoo source folder, the one that contains `odoo/` and `addons/`, to your workspace so core models, fields and templates are suggested too.

## Python suggestions

Items marked **index** need the workspace index to be ready.

| You type | You get |
| :--- | :--- |
| `fields.` | The field classes of your Odoo version, such as `Char`, `Many2one` and `Properties`, inserted as `Char(string="...")`. |
| `=` inside a `fields.X(...)` call | The parameters that field accepts in your version, such as `string`, `required`, `compute`, `ondelete` and `tracking`. |
| `@` | The `api` decorators of your version, such as `api.depends`, `api.constrains`, `api.onchange` and `api.model_create_multi`. |
| `fields.Many2one('`, `One2many`, `Many2many` or `comodel_name='` | Model names. **index** |
| `_inherit = '` as a 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.` or `record.` in a loop such as `for record in self` | The fields of the current model, and through relations. **index** |
| `@api.depends('` or `@api.onchange('` | The fields of the current model. **index** |
| `def _compute_`, `def _inverse_` or `def _search_` | The field names of the current class, to complete the method name. |
| `def ` in a class with `_inherit` | The methods of the inherited model. Choosing one inserts the override with a `super()` call. **index** |
| `odoo` | The [Python snippets](/assista-ide/snippets/python-snippets), including the import snippets. |

### Follow relations

A chain of relational fields keeps going as deep as you write it. The suggestions are the fields of the last model in the chain.

```python
class PurchaseOrder(models.Model):
    _name = 'purchase.order'
    order_line_ids = fields.One2many('purchase.order.line', 'order_id')

class PurchaseOrderLine(models.Model):
    _name = 'purchase.order.line'
    product_id = fields.Many2one('product.product')

# Inside a method of purchase.order:
self.order_line_ids.product_id.   # suggests the fields of product.product
```

If a field in the chain is not a relation, the suggestions stop there.

## XML suggestions

| Where the cursor is | You get |
| :--- | :--- |
| After `<` | The tags of your Odoo version: data tags such as `record`, `field`, `menuitem` and `template`, every view type (`form`, `list`, `kanban`, `card` on Odoo 20, `search`, `calendar`, `graph`, `pivot`, `activity`, `hierarchy`), view elements and QWeb `t`. |
| Inside a tag | Only the attributes that tag accepts in your version, for example `card_id` and `dialog_size` on Odoo 20. |
| `<field name="` or `<filter name="` in a view | The fields of the view's model, taken from the `model` field of the view record. This works in every view type. **index** |
| `<button name="` with `type="object"` | The methods of the view's model. **index** |
| `<record model="` | Model names. **index** |
| The text of `<field name="model">` in a view, or `<field name="res_model">` in a window action | Model names. **index** |
| The text of `<field name="view_mode">` | `list`, `form`, `kanban`, `pivot`, `graph`, `calendar`, `activity` and `hierarchy`. |
| The text of `<field name="tag">` in an `ir.actions.client` record | The client action tags registered in JavaScript. **index** |
| `widget="` on a field | The 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` and `attributes`. |
| `class="` | CSS classes, starting with the current module, then `web`, `base`, `mail` and `portal`, then the rest. **index** |
| `odoo` | The [XML snippets](/assista-ide/snippets/xml-snippets). |

## Manifest suggestions

In `__manifest__.py`:

* **`depends`**: when you open a quote on a line that contains `depends`, you get the module names in your workspace. **index**
* **`data`, `demo` and `assets` paths**: you get the module's files and folders as you type a path. Choosing a folder continues into it. Asset paths start with the module name, for example `my_module/static/src/...`, as Odoo expects.

## Go to definition

Press `F12` or `Ctrl+Click` (`Cmd+Click` on macOS) on a name to jump to where it is defined. Use `Alt+F12` to peek at the definition without leaving the file. When a name has several definitions, you get a list.

**From XML**

| On | Goes to |
| :--- | :--- |
| `<field name="...">` or `<filter name="...">` in a view | The field in Python. |
| `<button name="..." type="object">` | The Python method. |
| `model="..."`, `<field name="model">` or `<field name="res_model">` | The model class. |
| `ref="..."`, `inherit_id="..."`, `parent="..."` or `action="..."` | The XML record, menu item or template with that ID. |
| `t-call="..."` or `t-name="..."` | The QWeb template. |
| `widget="..."` | The JavaScript registration of the widget. |
| `<field name="tag">` in a client action | The JavaScript registration of the action. |
| A class in `class="..."` | Its CSS or SCSS definition in the current module, `web` or `mail`. Needs advanced CSS indexing. |

**From Python**

| On | Goes to |
| :--- | :--- |
| A model name in `_inherit` | The definitions of the model. |
| `self.env['model.name']` | The model class. |
| `self.field_name` or `self.partner_id.name` | The field or method, following relations. |
| `related='partner_id.country_id'` | The field at the end of the chain. |
| A module name in the manifest `depends` | That module's `__manifest__.py`. |
| A path in the manifest `data`, `demo` or `assets` | The file, or the folder in the Explorer. |

## Settings

Open **Settings** and search for `cybrosys-assista-odoo-helper`. Each setting below starts with `cybrosys-assista-odoo-helper.`.

| Setting | Default | Use it to |
| :--- | :--- | :--- |
| `odooSourcePath` | Empty | Point to the Odoo source folder, the one with `odoo/release.py`, when it is not in your workspace. It helps version detection and the CSS class suggestions. |
| `indexing.enableAdvanceCSSIndexing` | Off | Turn on go to definition for CSS classes. |
| `indexing.enableCoreIndexing` | On | Index Python models, fields and methods. Most suggestions and navigation need it. |
| `indexing.enableRegistryIndexing` | On | Index JavaScript registries, for widget, client action and public component suggestions. |
| `indexing.enableCSSIndexing` | On | Index CSS and SCSS classes, for `class="` suggestions. |

Turn off indexing you do not use to speed up very large workspaces.

## Troubleshooting

* **No suggestions at all.** Check that the folder you opened contains a `__manifest__.py` or an `odoo/release.py`, and that the status bar shows an Odoo version.
* **Model or field names are missing.** Wait for the first index to finish. If the index looks outdated, run **Assista: Remove Index Data (Clear Cache)** from the Command Palette, then reload the window to rebuild it.

## Tips and limits

* Go to definition works from XML and Python files, not from JavaScript.
* Inside an `<xpath>` of an inherited view, field suggestions use the view record rather than the inherited view's model.
* Suggestions for `depends` appear on lines that contain the word `depends`.

## Next steps

* Insert code with [Python snippets](/assista-ide/snippets/python-snippets) and [XML snippets](/assista-ide/snippets/xml-snippets).
* Turn on [Odoo coding standard warnings](/assista-ide/odoo-standards/standards).
