---
url: https://docs.cybrosys.com/vs-code-extension/features/model-tools.md
description: >-
  Generate views, QWeb reports and access rights from an Odoo model class, with
  output that follows your Odoo version.
---

# Model tools

Generate views, a QWeb report or an access rule from the model class under your cursor. The extension reads the model's fields from its index and writes files for your Odoo version.

## What you can do

| Tool | Result |
|---|---|
| **Create Views** | `views/<model>_views.xml` with the views, window action and menu you choose. |
| **Create Report** | `report/<model>_pdf_report.xml` or `report/<model>_html_report.xml`. |
| **Create Access Right** | A full-access row for internal users in the access file of your version. |
| **Model Inheritance Graph** | A graph of the model and every module that extends it. |

The new files are added to the manifest and opened. Here `<model>` is the technical name with dots replaced by underscores, for example `sale_order`.

## Get started

1. Open a Python file in an Odoo module and place the cursor inside a model class.
2. Right-click and select **Odoo Model Tools**. The menu appears only inside a model class.
3. Choose **Create Views**, **Create Report**, **Create Access Right** or **Model Inheritance Graph**.

You can also right-click the editor tab to open the same menu.

## Create Views

1. Choose the components. **Form View**, **List View**, **Search View**, **Window Action** and **Menu** are ticked by default. **Kanban View**, **Calendar View** and **Pivot View** are not.
2. Choose a creation mode.

| Mode | What you get |
|---|---|
| **Quick Create** | Every field that each view supports. |
| **Advanced Builder** | A field picker for each view. The first five fields that the view supports are ticked. |

In the Advanced Builder, each picker lists only the fields that view can show. For a `One2many` field in the form, a second picker asks which columns of the related model to show in the embedded list.

### What the views contain

| Component | Output |
|---|---|
| Form | The `name` field as a title, other fields in two columns, and a notebook page for each `Text`, `Html` or `One2many` field. A `One2many` page holds an editable list of the columns you chose. |
| List | The fields you chose, as a `<list>`. |
| Search | The fields you chose, and a **Group By** filter for each `Many2one`, `Selection`, `Date`, `Datetime` or `Boolean` field. |
| Kanban | A `card` template with the fields you chose. |
| Calendar | A calendar that starts on the first date field you chose. It is skipped if you choose no date field. |
| Pivot | Number fields as measures and other fields as rows. Date fields group by month. |
| Window action | The views you chose as `view_mode`. The form comes last, so the action never opens on a blank form. |
| Menu | A `menuitem` for the action. |

`Many2many` fields use the `many2many_tags` widget. Image fields use the `image` widget. The form adds `<chatter/>` when the model inherits `mail.thread`.

### Limits

* The model must define `_name`. Views for a model that only extends another with `_inherit` are not supported, and the extension tells you so.
* If `views/<model>_views.xml` exists, the extension shows a warning and does not overwrite it.

## Create Report

1. Choose **PDF Report** or **HTML**.
2. Choose the title field, for example `name`.
3. Choose the fields shown in the header information section.
4. Optionally choose a `One2many` or `Many2many` field for a lines table, then choose its columns.

The title and header pickers offer `Char`, `Text`, `Integer`, `Float`, `Monetary`, `Boolean`, `Selection` and `Date` fields.

The extension writes an `ir.actions.report` record, bound to the model so it appears in the **Print** menu, and a QWeb template based on `web.external_layout`. If the report file already exists, the extension shows a warning and does not overwrite it.

## Create Access Right

Adds a rule for the model, for internal users (`base.group_user`), with full permissions.

**Odoo 20**
The row goes in `security/ir.access.csv`, with `operation` set to `crud`.

```csv
id,name,model_id,group_id/id,operation,domain
access_library_book_user,library.book user,library.book,base.group_user,crud,
```

**Odoo 18 and 19**
The row goes in `security/ir.model.access.csv`.

```csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_library_book_user,library.book user,model_library_book,base.group_user,1,1,1,1
```

The extension creates the `security` folder and the file with its header if needed, adds the file to the manifest and opens it. If the model already has a row, it adds nothing and tells you so.

## Model Inheritance Graph

Shows the model at the cursor, every module that extends it, and the fields and methods each one adds. Double-click a node to open its code. If you connect an [Odoo server](/vs-code-extension/features/odoo-connectivity), the graph also shows which modules are installed.

The command is also in the Command Palette while a Python file with a model is active.

## Tips and limits

* The tools work inside an Odoo module, which is a folder with a `__manifest__.py`.
* The Model Inheritance Graph needs an internet connection, because it loads its graph library from `unpkg.com`.
* Fields come from the index. Wait for the index to finish after you add a field.
* To create a single XML or CSV file by name instead, use the [File creator](/vs-code-extension/features/file-creator).

## Next steps

* [File creator](/vs-code-extension/features/file-creator)
* [Odoo connectivity](/vs-code-extension/features/odoo-connectivity)
