--- name: odoo-xml-views description: XML/Odoo views conventions for this repo (XPath, inheritance, IDs, security, manifest data). Use when editing .xml views, security/, or XML data in Odoo addons. metadata: type: reference --- # XML (Odoo Views) ## Style and conventions - Indentation: **4 spaces** (no tabs). - XPath with explicit `position`: `before`, `after`, `inside`, `replace`, `attributes`. - Reference groups via `module.xml_id` (e.g. `sales_team.group_sale_manager`). - `sequence` to order fields in views. - IDs: `module.descriptive_name` pattern. - **No conditional logic in QWeb**, only access to attributes prepared in the controller. - Translate strings in XML, never with `_()` in Python field definitions. ## Key patterns - Views in `views/*.xml`. Typical manifest `data` order: `security/ir.model.access.csv`, `views/actions.xml`, `views/menu.xml`, `views/_views.xml`. - Security: `id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink`. - Common groups: `base.group_user`, `base.group_system`, `sales_team.group_sale_manager`, `purchase.group_purchase_manager`. ## Common mistakes - *XPath not found* → check inheritance chain and correct XML IDs. - Complex logic in QWeb → move it to the controller (see `docs/QWEB_BEST_PRACTICES.md`).