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>
1.9 KiB
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/). |
|
Python (Odoo ORM)
Style and conventions
- Follow the OCA guidelines strictly.
black(line length 88) for formatting,isort(black profile) for imports.- Mandatory linting:
flake8andpylint-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.Modelormodels.TransientModel(wizards). - Business fields ALWAYS on
product.product, not onproduct.template(userelatedon the template). Avoids issues with pricelists and reports that operate at the variant level. @api.depends(...)for computed fields.- Notifications:
ir.actions.clientwithdisplay_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)). Validateproduct.taxes_idbefore computing (raiseUserErrorif missing).
Testing
- Tests in each addon's
tests/, namedtest_*.py, inheriting fromodoo.tests.common.TransactionCase. - Run (use
run, notexec, 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.