unclecatvn/agent-skills / skills/odoo-19.0
odoo-19
VerifiedOdoo 19 development knowledge base with 18 specialized guides covering Actions (ir.actions.*, cron jobs, server actions), Controllers (HTTP routing, endpoints, auth types), Data files (XML/CSV records, shortcuts, noupdate), API Decorators (@api.depends, @api.constrains, @api.ondelete, @api.onchange, @api.model, @api.private), SQL Constraints (models.Constraint replacing _sql_constraints), Database Indexes (models.Index), Module development (manifest, wizards, reports), Field types (Char, Text, Monetary, relational fields), Manifest configuration (__manifest__.py, dependencies, asset bundles), Mixins (mail.thread, mail.activity.mixin, mail.alias.mixin, utm.mixin), ORM Model methods (search, CRUD, domain filters, recordsets, CamelCase model naming), Migration scripts (pre/post/end hooks, data migration), OWL frontend components (hooks, services, lifecycle), Performance optimization (N+1 prevention, batch ops, _read_group), QWeb Reports (PDF/HTML, paper formats, barcodes, t-out), Security/ACL (record rules, field permissions, privilege-based groups, @api.private), Testing (TransactionCase, HttpCase, mocking, query count assertions), Transactions (savepoints, UniqueViolation, serialization failures), Translations (i18n, PO files, translatable fields), XML Views (list/form/search, kanban card templates, xpath inheritance, QWeb templates). Use when writing, reviewing, or debugging any Odoo 19 Python or XML code, creating or modifying modules, fixing performance issues, or looking up Odoo 19 API patterns and best practices. Includes CSS/SCSS asset authoring and review for Odoo addons.
references/odoo-19-data-guide.md
View on GitHub# Odoo 19 Data Files Guide
## Coding Conventions
- Use stable, descriptive XML IDs, prefixed by the target model or feature;
never use numeric or presentation-only IDs.
- Format XML with one attribute per line when it improves readability, keep
records in dependency order, and use `noupdate="1"` only for data that must
not be overwritten on upgrade.
Guide for working with Odoo 19 data files (XML and CSV), records, and shortcuts.
## Table of Contents
- [XML Data Files Structure](#xml-data-files-structure)
- [Record Tag](#record-tag)
- [Field Tag](#field-tag)
- [Delete Tag](#delete-tag)
- [Function Tag](#function-tag)
- [Shortcuts](#shortcuts)
- [CSV Data Files](#csv-data-files)
---
## XML Data Files Structure
The main way to define data in Odoo is via XML data files:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<operation/>
...
</odoo>
```
### noupdate Flag
If content should only be applied once:
```xml
<odoo>
<data noupdate="1">
<!-- Only loaded when installing the module -->
<operation/>
</data>
<!-- (Re)Loaded at install and update -->
<operation/>
</odoo>
```
---
## Record Tag
`record` - Defines or updates a database record.
### Attributes
| Attribute | Type | Required | Description |
| ------------- | ------ | -------- | ---------------------------------------------------------- |
| `model` | string | Yes | Name of the model to create/update |
| `id` | string | No\* | External identifier for this record (strongly recommended) |
| `context` | dict | No | Context to use when creating |
| `forcecreate` | bool | No | In update mode, create if doesn't exist (default: True) |
\*Required for record updates; recommended for creation
### Example
```xml
<record id="partner_1" model="res.partner">
<field name="name">Odoo</field>
<field name="is_company" eval="True"/>
<field name="customer_rank" eval="1"/>
</record>
```
---
## Field Tag
Each `record` can have `field` tags defining values.
### Attributes
| Attribute | Type | Description |
| --------- | ------ | ----------------------------------------- |
| `name` | string | **Required**. Name of the field to set |
| `ref` | string | External ID to look up and set |
| `search` | domain | Search domain, result set as field value |
| `eval` | string | Python expression to evaluate |
| `type` | string | Interpret field content (see types below) |
### Value Methods
#### Nothing (False)
```xml
<field name="description"/>
```
#### search
For relational fields, evaluates a domain and sets the result:
```xml
<field name="partner_id" search="[('name', '=', 'Odoo')]"/>
```
Only first result used for Many2one fields.
#### ref
Look up an external ID:
```xml
<field name="country_id" ref="base.vn"/>
<field name="user_id" ref="base.user_admin"/>
```
#### type
Available types:
| Type | Description |
| --------------- | ------------------------------------------------------ |
| `xml`, `html` | Extract children as document, evaluate external IDs |
| `file` | Ensure content is valid file path, saves `module,path` |
| `char` | Set content directly without alterations |
| `base64` | Base64-encode content (use with `file` attribute) |
| `int`, `float` | Convert to number |
| `list`, `tuple` | Contains `value` elements |
```xml
<field name="description" type="xml">
<p>Hello <t t-out="user.name"/></p>
</field>
<field name="image" type="base64" file="static/img/logo.png"/>
```
#### eval
Evaluate a Python expression:
```xml
<field name="active" eval="True"/>
<field name="date_today" eval="time.strftime('%Y-%m-%d')"/>
<field name="partner_id" eval="ref('base.main_partner')"/>
```
Evaluation context:
- `time` module; `datetime` / `DateTime`, `timedelta`, `relativedelta` are the classes, not the
modules (`datetime.now()`, not `datetime.datetime.now()`)
- `ref()` function to resolve external IDs
- `obj` for current field's model
---
## Delete Tag
`delete` - Removes records.
### Attributes
| Attribute | Type | Required | Description |
| --------- | ------ | -------- | -------------------------------- |
| `model` | string | Yes | Model in which to delete |
| `id` | string | No\* | External ID of record to remove |
| `search` | domain | No\* | Domain to find records to remove |
\*Exclusive: use either `id` or `search`
### Examples
```xml
<!-- Delete by external ID -->
<delete model="ir.ui.view" id="my_module.unwanted_view"/>
<!-- Delete by search -->
<delete model="ir.ui.menu" search="[('name', '=', 'Old Menu')]"/>
```
---
## Function Tag
`function` - Calls a method on a model.
### Attributes
| Attribute | Type | Required | Description |
| --------- | ------ | -------- | ----------------------- |
| `model` | string | Yes | Model to call method on |
| `name` | string | Yes | Name of method to call |
### Parameters
Via `eval` (should evaluate to sequence):
```xml
<function model="res.partner" name="send_inscription_notice"
eval="[[ref('partner_1'), ref('partner_2')]]"/>
```
Via `value` elements:
```xml
<function model="res.users" name="send_vip_inscription_notice">
<function eval="[[('vip','=',True)]]" model="res.partner" name="search"/>
</function>
```
---
## Shortcuts
Because some structural models are complex, data files provide shorter alternatives.
### menuitem
Defines an `ir.ui.menu` record with defaults:
| Attribute | Description |
| --------- | ------------------------------------------------------------------------- |
| `parent` | External ID of parent menu, or interpret `name` as `/`-separated sequence |
| `name` | Menu name (or get from linked action) |
| `groups` | Comma-separated external IDs for `res.groups` (prefix `-` removes group) |
| `action` | External ID of action to execute |
| `id` | External identifier |
```xml
<menuitem id="my_module_menu_root" name="My Module" web_icon="my_module,static/description/icon.png"/>
<menuitem id="my_module_menu" name="My Model" parent="my_module_menu_root" action="my_module_action"/>
```
### template
Creates a QWeb view requiring only the `arch` section:
| Attribute | Description |
| ------------ | ---------------------------------------------- |
| `id` | External identifier |
| `name` | View name |
| `inherit_id` | External ID of parent view |
| `priority` | View priority |
| `primary` | If True with `inherit_id`, defines as primary |
| `groups` | Comma-separated group external IDs |
| `active` | Whether view is active (for inheritance views) |
```xml
<template id="my_template" name="My Template">
<t t-call="website.layout">
<div class="oe_structure">
<h1>My Content</h1>
</div>
</t>
</template>
```
### asset
Creates an `ir.asset` record:
```xml
<asset id="website_something.some_style_asset" name="Some style asset" active="False">
<bundle>web.assets_frontend</bundle>
<path>website_something/static/src/some_style.scss</path>
</asset>
```
---
## CSV Data Files
XML is verbose for bulk creation. CSV files are simpler for same-model records.
### Structure
- File name: `{model_name}.csv`
- First row: fields to write, special field `id` for external IDs
- Each row: creates a new record
### Example: `res.country.state.csv`
```csv
id,country_id,name,code
state_1_us,country_us,Alabama,AL
state_2_us,country_us,Alaska,AK
state_3_us,country_us,Arizona,AZ
```
### Notes
- First column: external ID for creation/update
- Second column: external ID of country object to link to
- Third column: `name` field value
- Fourth column: `code` field value
---
## References
- Source: Odoo 19 documentation `/doc/developer/reference/backend/data.rst`
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |