addons-cm/CLAUDE.md
2026-06-26 19:42:45 +02:00

91 lines
4.8 KiB
Markdown

# Kidekoop — Odoo 18.0 Custom Addons
Odoo 18.0 (OCB community) addons repo. Code in **English**, UI in **Basque/Spanish**.
Combines OCB (`ocb/`), inherited OCA addons, and our own custom addons.
## ⚠️ Critical rules (non-negotiable)
- **DO NOT modify** the OCB core (`ocb/`) nor these original OCA addons (reference/inheritance only):
`product_main_seller`, `account_invoice_triple_discount`, `product_get_price_helper`,
`product_price_category`, `purchase_triple_discount`, `base_bank_from_iban`, `l10n_es_partner`.
All changes go in our own custom addons.
- **Do NOT use `_()` in field definitions** (triggers import-time warnings). Only in methods/executable code.
- **Business logic ALWAYS on `product.product`** (variants), never on `product.template` (use `related` there).
Avoids issues with pricelists and reports that operate at the variant level.
- **No logic in QWeb**: prepare all data in the Python controller; templates only do simple attribute access.
- **No business logic in JavaScript**: UI/events only.
- Translations: edit `.po` files with `polib` (append). **`msgmerge` corrupts the files** — do not use it.
## Stack
Odoo 18.0 · Python 3.10+ · PostgreSQL · Docker Compose · XML/QWeb/JS.
Formatting: `black` (line 88) + `isort` (black profile) + `flake8` + `pylint-odoo`. Pre-commit active.
## Commands
```bash
docker-compose up -d # env (8070=web, 8073=longpolling)
docker-compose run odoo odoo -d odoo --test-enable --stop-after-init -u <addon> # tests (run, NOT exec: avoids cache)
docker-compose exec odoo odoo -d odoo -u <addon> --stop-after-init # update addon
docker-compose logs -f odoo # logs
docker-compose exec db psql -U odoo -d odoo # postgres
make lint | make format | make check-format | make flake8 | make pylint-required
pre-commit run --all-files
```
## Odoo conventions
- Models `snake.case` · classes `PascalCase` · files `snake_case.py` · XML IDs `module.name`.
- Manifest always `__manifest__.py`, version `18.0.X.Y.Z`, `depends` alphabetically ordered.
- Views: 4 spaces, explicit `position` in XPath, groups via `module.xml_id`, `sequence` for ordering.
- Bulk: prefer `search().write()` over loops; `create([vals, ...])` for bulk create.
- Notifications: `ir.actions.client` + `display_notification`.
- Detailed logging in price/discount computations: `_logger.info("[PRICE] ...", ...)`.
- i18n: each addon ships `i18n/{es,eu}.po` (mandatory) + `.pot`. UTF-8 charset.
## Custom addons
Pricing & products:
- `product_sale_price_from_pricelist` — auto-computes sale price from last purchase price + pricelist.
Requires taxes on the product and `last_purchase_price_compute_type != "manual_update"`.
Also applies supplier discounts from `supplierinfo`.
- `product_pricelist_total_margin` — total margin computed additively (Markup or Commercial Margin), with global limits.
- `product_price_category_supplier` — price categories per supplier.
- `product_origin_char` — free-text origin field per product (template-based).
- `account_invoice_triple_discount_readonly` — fix for triple-discount accumulation bug (always use it).
Sales & website:
- `website_sale_aplicoop` — Eskaera: collaborative purchasing for consumer co-ops (group orders,
per-member carts, cutoff/pickup dates, lazy loading, multi-language).
- `portal_event_registration` — portal users view their event registrations + upload attachments to chatter.
Membership:
- `membership_monthly_invoicing` — auto-creates a monthly membership invoice per active member (cron-driven).
- `membership_expiry_reminder` — automated renewal-reminder emails near expiry, with online renew link.
Logistics & accounting:
- `stock_picking_batch_custom` — batch picking extras: extra detailed-op columns, ordering by
category/product/partner, and a full-screen operator (Basket Assembly) view.
- `account_banking_mandate_batch` — contextual action to bulk-create/validate SEPA mandates for selected partners.
- `l10n_es_edi_tbai_reagyp_recibidas` — TicketBAI fix: REAGYP vendor-bill regime key 19 → 02.
## Documentation
- Per-addon details: its `README.rst` (OCA) or `README_DEV.md` (technical).
- Global patterns: `.github/copilot-instructions.md` (extended version of this file).
- Guides: `docs/QWEB_BEST_PRACTICES.md`, `docs/OCA_DOCUMENTATION.md`, `docs/LAZY_LOADING.md`.
- OCA `readme/` structure (DESCRIPTION, INSTALL, CONFIGURE, USAGE, CONTRIBUTORS, CREDITS).
Credits: Criptomart (author) + Elika Bilbo (funder).
## Commits
`[TAG] module: description` — tags: `[ADD] [FIX] [IMP] [REF] [REM] [I18N] [DOC]`.
## Available skills
Per-language skills (`odoo-python`, `odoo-xml-views`, `odoo-qweb-html`, `odoo-javascript`) and the
OpenSpec workflow (`openspec-explore/propose/apply-change/archive-change`, `/opsx:*` commands) live in `.claude/`.