addons-cm/.claude/skills/odoo-python/SKILL.md
GitHub Copilot 9a7dfe02db [ADD] Claude Code ecosystem adapted from Copilot config
Port .github Copilot setup to Claude Code:
- CLAUDE.md: condensed project instructions (auto-loaded each session)
- .claude/skills: per-language guides (odoo-python, odoo-xml-views,
  odoo-qweb-html, odoo-javascript) + openspec-* workflow skills
- .claude/commands/opsx: /opsx:explore|propose|apply|archive slash commands

Original .github/ files kept untouched as extended reference.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 13:29:10 +02:00

1.9 KiB

name description metadata
odoo-python Python/Odoo ORM conventions for this repo (models, fields, computed, tests, OCA). Use when writing or modifying Python code in Odoo addons (.py, models/, wizards/, tests/).
type
reference

Python (Odoo ORM)

Style and conventions

  • Follow the OCA guidelines strictly.
  • black (line length 88) for formatting, isort (black profile) for imports.
  • Mandatory linting: flake8 and pylint-odoo.
  • Docstrings on classes and public methods; inline comments only for complex logic.
  • Do NOT use _() in field definitions (import-time warning). Only in executable methods.

Key patterns

  • Models inherit from models.Model or models.TransientModel (wizards).
  • Business fields ALWAYS on product.product, not on product.template (use related on the template). Avoids issues with pricelists and reports that operate at the variant level.
  • @api.depends(...) for computed fields.
  • Notifications: ir.actions.client with display_notification (type: success/warning/danger/info).
  • Detailed price/discount logging: _logger.info("[PRICE] Product %s [%s]: ...", code, id, ...).
  • Bulk updates: prefer search().write() over loops; create([vals, ...]) for bulk create.
  • Pricing: use product_get_price_helper (product._get_price(qty=1, pricelist=pricelist)). Validate product.taxes_id before computing (raise UserError if missing).

Testing

  • Tests in each addon's tests/, named test_*.py, inheriting from odoo.tests.common.TransactionCase.
  • Run (use run, not exec, for a clean container):
    docker-compose run odoo odoo -d odoo --test-enable --stop-after-init -u <addon>
    

Common mistakes

  • _() in module-level field definitions → warning. Remove it; translation goes through .po.
  • Computed fields failing in pricelists/reports → move logic to product.product.