feat(odoo): add dynamic model prop to support all Odoo models#20271
feat(odoo): add dynamic model prop to support all Odoo models#20271NicolasStuff wants to merge 6 commits intoPipedreamHQ:masterfrom
Conversation
Currently the Odoo component has 'res.partner' hardcoded in makeRequest(), limiting all operations (create, update, search_read) to Contacts only. This adds a 'model' prop to each action, allowing users to work with any Odoo model (CRM leads, sales orders, invoices, etc.). Defaults to 'res.partner' for backward compatibility. Resolves the original requirement from PipedreamHQ#15359 which specified a model prop.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
|
Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:
|
WalkthroughAdds a required public Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Action as Action Handler
participant App as Odoo App
participant API as Odoo API
User->>Action: Select model & execute action
Action->>App: getFieldProps(model)
App->>API: fields_get for model
API-->>App: field definitions
App-->>Action: field props
Action->>App: createRecord/searchAndReadRecords/updateRecord(model, data)
App->>API: execute_kw(model, method, ...)
API-->>App: result
App-->>Action: response
Action-->>User: result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
luancazarine
left a comment
There was a problem hiding this comment.
Hi @NicolasStuff, I just added some suggestions. Take a look and let me know if you have any questions.
Co-authored-by: Luan Cazarine <luanhc@gmail.com>
…s.mjs Co-authored-by: Luan Cazarine <luanhc@gmail.com>
Co-authored-by: Luan Cazarine <luanhc@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
components/odoo/actions/create-record/create-record.mjs (1)
15-18: 🧹 Nitpick | 🔵 TrivialAddress linter warnings for the
odooprop.The pipeline reports warnings that the
odooprop lackslabelanddescription. While this is a pre-existing pattern, consider addressing it since you're modifying this file.♻️ Proposed fix
odoo: { ...odoo, + label: "Odoo", + description: "The Odoo app instance", reloadProps: true, },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@components/odoo/actions/create-record/create-record.mjs` around lines 15 - 18, The linter warns that the odoo prop is missing metadata; update the prop definition for "odoo" in create-record.mjs to include a descriptive "label" and "description" (alongside the existing properties like reloadProps) so the prop schema is complete; locate the object that contains the odoo key (the one currently spreading ...odoo and setting reloadProps: true) and add meaningful label and description fields to that prop entry.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@components/odoo/actions/search-read-records/search-read-records.mjs`:
- Around line 17-22: The model prop definition currently lacks reloadProps and
changing the model won't refresh async options for the fields prop; update the
model prop (the object with propDefinition: [odoo, "model"]) to include
reloadProps: true so that the fields prop's async options (which depend on
this.model) are reloaded when model changes.
- Line 42: The line assigning response calls this.odoo.searchAndReadRecords(...)
and exceeds the 100-char lint limit; split the call across multiple lines (e.g.,
place the method arguments on separate lines) so the const response = await
this.odoo.searchAndReadRecords( ... ) expression is wrapped under 100 characters
while preserving the same arguments (this.model, parseObject(this.filter), args)
and keeping the await and assignment to response unchanged.
---
Outside diff comments:
In `@components/odoo/actions/create-record/create-record.mjs`:
- Around line 15-18: The linter warns that the odoo prop is missing metadata;
update the prop definition for "odoo" in create-record.mjs to include a
descriptive "label" and "description" (alongside the existing properties like
reloadProps) so the prop schema is complete; locate the object that contains the
odoo key (the one currently spreading ...odoo and setting reloadProps: true) and
add meaningful label and description fields to that prop entry.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 08a9fdbc-1518-4045-b723-ad03c0fe5bb3
📒 Files selected for processing (3)
components/odoo/actions/create-record/create-record.mjscomponents/odoo/actions/search-read-records/search-read-records.mjscomponents/odoo/actions/update-record/update-record.mjs
…s.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@components/odoo/package.json`:
- Line 3: Update the package.json version from 0.1.1 to 0.2.0 to reflect the new
public `model` prop feature; locate the "version" field in package.json
(currently "version": "0.1.1") and change it to "0.2.0" so the release follows
the repo's semver minor-bump policy for new features.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: d555879d-77d0-4a07-a7d7-f36808472cd1
📒 Files selected for processing (2)
components/odoo/actions/search-read-records/search-read-records.mjscomponents/odoo/package.json
|
Resolved by #20483 |
Summary
The Odoo component currently has
"res.partner"hardcoded inmakeRequest(), which limits all operations (create, update, search & read) to Contacts only. This was flagged in the original spec (#15359) which explicitly required amodelprop, but the implementer hardcodedres.partnerinstead.This PR adds a
modelprop to each action, allowing users to work with any Odoo model — CRM leads (crm.lead), sales orders (sale.order), invoices (account.move), and more.Changes
odoo.app.mjs: AddedmodelpropDefinition, updatedmakeRequest(model, method, filter, args)signature, updated all helper methods (getFields,searchAndReadRecords,createRecord,updateRecord,readRecord,getFieldProps) to acceptmodelas first parametercreate-record.mjs: Addedmodelprop, passes it tocreateRecord()andgetFieldProps()search-read-records.mjs: Addedmodelprop, passes it tosearchAndReadRecords()update-record.mjs: Addedmodelprop, passes it toupdateRecord(),getFieldProps(), andgetRecordIdOptions()Backward Compatibility
The
modelprop defaults to"res.partner", so existing users will not be affected.Related
Summary by CodeRabbit
New Features
Updates