Antigravity-awesome-skills odoo-orm-expert
Master Odoo ORM patterns: search, browse, create, write, domain filters, computed fields, and performance-safe query techniques.
install
source · Clone the upstream repo
git clone https://github.com/sickn33/antigravity-awesome-skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/sickn33/antigravity-awesome-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/plugins/antigravity-awesome-skills/skills/odoo-orm-expert" ~/.claude/skills/sickn33-antigravity-awesome-skills-odoo-orm-expert-c6c149 && rm -rf "$T"
manifest:
plugins/antigravity-awesome-skills/skills/odoo-orm-expert/SKILL.mdsafety · automated scan (low risk)
This is a pattern-based risk scan, not a security review. Our crawler flagged:
- references .env files
Always read a skill's source content before installing. Patterns alone don't mean the skill is malicious — but they warrant attention.
source content
Odoo ORM Expert
Overview
This skill teaches you Odoo's Object Relational Mapper (ORM) in depth. It covers reading/writing records, building domain filters, working with relational fields, and avoiding common performance pitfalls like N+1 queries.
When to Use This Skill
- Writing
,search()
,browse()
,create()
, orwrite()
calls.unlink() - Building complex domain filters for views or server actions.
- Implementing computed, stored, and related fields.
- Debugging slow queries or optimizing bulk operations.
How It Works
- Activate: Mention
and describe what data operation you need.@odoo-orm-expert - Get Code: Receive correct, idiomatic Odoo ORM code with explanations.
- Optimize: Ask for performance review on existing ORM code.
Examples
Example 1: Search with Domain Filters
# Find all confirmed sale orders for a specific customer, created this year import datetime start_of_year = datetime.date.today().replace(month=1, day=1).strftime('%Y-%m-%d') orders = self.env['sale.order'].search([ ('partner_id', '=', partner_id), ('state', '=', 'sale'), ('date_order', '>=', start_of_year), ], order='date_order desc', limit=50) # Note: pass dates as 'YYYY-MM-DD' strings in domains, # NOT as fields.Date objects — the ORM serializes them correctly.
Example 2: Computed Field
total_order_count = fields.Integer( string='Total Orders', compute='_compute_total_order_count', store=True ) @api.depends('sale_order_ids') def _compute_total_order_count(self): for record in self: record.total_order_count = len(record.sale_order_ids)
Example 3: Safe Bulk Write (avoid N+1)
# ✅ GOOD: One query for all records partners = self.env['res.partner'].search([('country_id', '=', False)]) partners.write({'country_id': self.env.ref('base.us').id}) # ❌ BAD: Triggers a separate query per record for partner in partners: partner.country_id = self.env.ref('base.us').id
Best Practices
- ✅ Do: Use
,mapped()
, andfiltered()
on recordsets instead of Python loops.sorted() - ✅ Do: Use
sparingly and only when you understand the security implications.sudo() - ✅ Do: Prefer
oversearch_count()
when you only need a count.len(search(...)) - ✅ Do: Use
to pass context values cleanly rather than modifyingwith_context(...)
directly.self.env.context - ❌ Don't: Call
inside a loop — this is the #1 Odoo performance killer.search() - ❌ Don't: Use raw SQL unless absolutely necessary; use ORM for all standard operations.
- ❌ Don't: Pass Python
/datetime
objects directly into domain tuples — always stringify them asdate
.'YYYY-MM-DD'
Limitations
- Does not cover
raw SQL patterns in depth — use the Odoo performance tuner skill for SQL-level optimization.cr.execute() - Stored computed fields can cause significant write overhead at scale; this skill does not cover partitioning strategies.
- Does not cover transient models (
) or wizard patterns.models.TransientModel - ORM behavior can differ slightly between Odoo SaaS and On-Premise due to config overrides.