care
care copied to clipboard
Amjith's Odoo
Odoo
Summary by CodeRabbit
-
New Features
- Odoo integration: automatic syncing of invoices, payments, delivery orders, products, categories, partners, and users; user-agent mapping and provisioning.
- New post-create behavior: newly created users without passwords receive a password-reset email.
-
Improvements
- Increased transactional safety for create/update operations to improve data consistency.
- Startup wiring and real-time hooks to trigger Odoo synchronizations; structured API payloads and end-to-end sync workflows.
-
Chore
- Added Odoo configuration, connector dependency, and planning TODOs.
📝 Walkthrough
Walkthrough
Adds an Odoo integration: new connector, Pydantic specs, resources to sync products/partners/users/invoices/payments/categories/delivery orders, signal handlers, AppConfig and model for user↔Odoo agent, ODOO_CONFIG setting, Pipfile addition, and transaction atomicity wrappers in multiple EMR viewsets.
Changes
| Cohort / File(s) | Summary |
|---|---|
Transaction management in EMR viewsets care/emr/api/viewsets/charge_item_definition.py, care/emr/api/viewsets/inventory/delivery_order.py, care/emr/api/viewsets/inventory/product.py, care/emr/api/viewsets/invoice.py, care/emr/api/viewsets/organization.py, care/emr/api/viewsets/payment_reconciliation.py, care/emr/api/viewsets/resource_category.py, care/emr/api/viewsets/user.py |
Imported django.db.transaction and wrapped perform_create / perform_update calls in with transaction.atomic(): blocks; UserViewSet.perform_create also attempts to send a password-reset email and raises to trigger rollback on send failure. |
Pipfile & settings Pipfile, config/settings/base.py |
Adds odoorpc==0.10.1 to Pipfile; adds ODOO_CONFIG dict in config/settings/base.py populated from environment variables. |
Django app bootstrap & TODO odoo/apps.py, odoo/TODO.md |
Adds OdooConfig AppConfig that imports odoo.signals on ready and adds odoo/TODO.md with integration planning notes. |
Connector & user mapping model odoo/connector/connector.py, odoo/models.py |
Adds OdooConnector.call_api() to build/auth POST requests to Odoo and a UserOdooAgent model mapping local users to Odoo agent IDs. |
Account-move specs & resources odoo/resource/account_move/spec.py, odoo/resource/account_move/invoice.py, odoo/resource/account_move/delivery_order.py |
Adds Pydantic models (discounts, AgentData, InvoiceItem, AccountMoveApiRequest/Return) and resources to assemble and POST invoice/vendor-bill payloads (invoice sync, invoice return, delivery-order sync). |
Payment specs & resources odoo/resource/account_move_payment/spec.py, odoo/resource/account_move_payment/payment.py |
Adds payment enums/models and OdooPaymentResource methods to sync payments and payment cancellations to Odoo. |
Product category spec & resource odoo/resource/product_category/spec.py, odoo/resource/product_category/category.py |
Adds CategoryData model and OdooCategoryResource.sync_category_to_odoo_api() to post categories (including parent relation). |
Product spec & resource odoo/resource/product_product/spec.py, odoo/resource/product_product/resource.py |
Adds TaxData, ProductStatus, ProductData models and OdooProductProductResource to extract pricing/taxes/category and sync charge-item/product data to Odoo. |
Partner spec & resource odoo/resource/res_partner/spec.py, odoo/resource/res_partner/resource.py |
Adds PartnerType enum and PartnerData model and OdooPartnerResource.sync_partner_to_odoo_api() to create partners from Organization data. |
User spec & resource odoo/resource/res_user/spec.py, odoo/resource/res_user/resource.py |
Adds UserType and UserData models and OdooUserResource (with full-name helper) and sync logic for users. |
Resourcing & shared specs odoo/resource/... |
Introduces multiple Pydantic spec modules referenced by resources to standardize payloads across API calls (category, product, partner, user, account-move, payments). |
Signal handlers odoo/signals.py |
Adds post_save receivers for User, Invoice, PaymentReconciliation, ChargeItemDefinition, ResourceCategory, Organization, DeliveryOrder, Product (and related models) to trigger corresponding Odoo syncs based on state/creation. |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~60 minutes
- Files needing extra scrutiny:
odoo/connector/connector.py— auth header construction, URL/port composition, and logging that may expose secrets.odoo/resource/account_move/invoice.py,odoo/resource/account_move/delivery_order.py,odoo/resource/product_product/resource.py— dense data-mapping and transformation logic; ensure required fields and error paths handled.odoo/signals.py— post_save semantics: avoid duplicate or premature syncs and inspect conditions for update vs create.- EMR viewset transaction wrappers — verify correct return/exception semantics and that moved super() calls preserve behavior.
Pre-merge checks and finishing touches
❌ Failed checks (2 warnings, 1 inconclusive)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Description check | ⚠️ Warning | The pull request description is extremely sparse—only the word 'Odoo' is provided—and does not follow the repository's description template structure. | Complete the description using the template: add a 'Proposed Changes' section summarizing the changes, link any associated issues, document architecture changes, and include the merge checklist items. |
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 44.90% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
| Title check | ❓ Inconclusive | The title 'Amjith's Odoo' is vague and doesn't clearly describe the main changes; it appears to be a person's name rather than a meaningful summary of the work. | Consider using a more descriptive title that summarizes the primary changes, such as 'Add Odoo integration module for syncing invoices, payments, and products' or 'Implement Odoo API connector and synchronization workflows'. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
amjith/odoo_module
Comment @coderabbitai help to get the list of available commands and usage tips.