Skip to content

Go to Definition ​

Jump from XML or Python to the Odoo definition you are looking at: a field, model, method, template, widget or file.

What you can do ​

Use F12, Ctrl+Click (Cmd+Click on macOS) or Peek Definition (Alt+F12).

From XML

OnGoes to
<field name="..."> or <filter name="..."> in a viewThe field in Python. Several definitions appear as a peek list.
<button name="..." type="object">The Python method.
model="...", <field name="model">, <field name="res_model">The model class.
ref="...", inherit_id="...", parent="...", action="..."The XML record, menu item or template with that ID.
t-call="...", t-name="..."The QWeb template.
widget="..."The JavaScript registration of the widget.
<field name="tag"> in a client actionThe JavaScript registration of the action.
A class in class="..."Its CSS or SCSS definition in the current module, web or mail. Turn on Advanced CSS Indexing.

From Python

OnGoes to
A model name in _inheritThe model's definitions.
self.env['model.name']The model class.
self.field_name, self.partner_id.nameThe field or method, following relations.
related='partner_id.country_id'The field at the end of the chain.
A module name in the manifest dependsThat module's __manifest__.py.
A path in the manifest data, demo or assetsThe file, or the folder in the Explorer.

Examples ​

Field in a view. Put the cursor on age and press F12. The extension finds the model from the <field name="model"> line above it.

xml
<record id="patient_view_form" model="ir.ui.view">
    <field name="model">hospital.patient</field>
    <field name="arch" type="xml">
        <form>
            <field name="age"/> <!-- opens the age field of hospital.patient -->
            <button name="action_confirm" type="object"/> <!-- opens the Python method -->
        </form>
    </field>
</record>

Model, field and method in Python.

python
class Patient(models.Model):
    _inherit = 'mail.thread'  # opens the mail.thread model

    def check_status(self):
        orders = self.env['sale.order'].search([])  # opens the sale.order model
        if self.state == 'draft':                   # opens the state field
            self.process_patient_data()             # opens the method
        return self.partner_id.country_id           # follows the relation

Manifest. Ctrl+Click a module name in depends to open its manifest. Ctrl+Click a path in data, demo or assets to open the file. Ctrl+Click a folder part of a path to show that folder in the Explorer.

python
'depends': ['base', 'hospital_management'],  # opens the hospital_management manifest
'data': ['security/ir.model.access.csv'],     # opens the file

Get started ​

  1. Open your Odoo workspace and wait for the background index to finish.
  2. Press F12 with the cursor on a name from the tables above.

Tips and limits ​

WARNING

Go to Definition needs the indexing settings turned on, in particular indexing.enableCoreIndexing. For CSS classes, also turn on indexing.enableAdvanceCSSIndexing.

  • Go to Definition works from XML and Python files, not from JavaScript.
  • For a field in a view, the model comes from the nearest <field name="model"> or <field name="res_model"> above the cursor in the same file. If none appears above it, the field does not resolve.
  • When a field, method or model has several definitions, they appear as a peek list. Pick the one you want.
  • Add the Odoo source folder to your workspace to jump into core models and templates.

Next steps ​

Built by Cybrosys Technologies.