fix(odoo): support dynamic model in actions#20483
fix(odoo): support dynamic model in actions#20483jcortes merged 18 commits intoPipedreamHQ:masterfrom
Conversation
…ting method signatures. Bump action versions to 0.0.3 for create, search-read, and update record actions. This allows for dynamic model interaction in Odoo API calls.
|
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:
|
WalkthroughThe pull request refactors Odoo integration components to support multiple models. A new Changes
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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
components/odoo/odoo.app.mjs (1)
53-108:⚠️ Potential issue | 🟠 MajorRestore default model fallback in helper methods to keep compatibility.
At Line 53 and Lines 94-107,
modelbecame mandatory with no defensive fallback. Any caller that omitsmodel(or passes an empty string) now fails at XML-RPC execution. Keep the model-aware API, but retain a safe default to preserve legacy behavior.Proposed fix
- async makeRequest(model, method, filter = [], args = {}) { + async makeRequest(model = "res.partner", method, filter = [], args = {}) { + const resolvedModel = model?.trim?.() || "res.partner"; const db = this.$auth.db; const uid = await this.getUid(); const password = this.$auth.password; const models = this.getClient("object"); const results = await new Promise((resolve, reject) => { models.methodCall("execute_kw", [ db, uid, password, - model, + resolvedModel, method, filter, args, ], (error, value) => { if (error) reject(error); resolve(value); }); }); return results; }, - async getFieldProps(model, { update = false } = {}) { + async getFieldProps(model = "res.partner", { update = false } = {}) { const props = {}; const fields = await this.getFields(model, [], {}); @@ - getFields(model, filter = [], args = {}) { + getFields(model = "res.partner", filter = [], args = {}) { return this.makeRequest(model, "fields_get", filter, args); }, - searchAndReadRecords(model, filter = [], args = {}) { + searchAndReadRecords(model = "res.partner", filter = [], args = {}) { return this.makeRequest(model, "search_read", filter, args); }, - readRecord(model, data) { + readRecord(model = "res.partner", data) { return this.makeRequest(model, "read", data); }, - createRecord(model, data) { + createRecord(model = "res.partner", data) { return this.makeRequest(model, "create", data); }, - updateRecord(model, data) { + updateRecord(model = "res.partner", data) { return this.makeRequest(model, "write", data); },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@components/odoo/odoo.app.mjs` around lines 53 - 108, The helper methods currently require a non-empty model and break callers that omit it; update makeRequest and the wrapper methods getFields, searchAndReadRecords, readRecord, createRecord, and updateRecord to defensively fall back to a default model when model is falsy (e.g., model = model || this.defaultModel || this.model || ""). Ensure makeRequest uses the resolved model variable when calling models.methodCall so existing callers that omit or pass an empty model keep legacy behavior while still allowing explicit model overrides.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@components/odoo/odoo.app.mjs`:
- Around line 53-108: The helper methods currently require a non-empty model and
break callers that omit it; update makeRequest and the wrapper methods
getFields, searchAndReadRecords, readRecord, createRecord, and updateRecord to
defensively fall back to a default model when model is falsy (e.g., model =
model || this.defaultModel || this.model || ""). Ensure makeRequest uses the
resolved model variable when calling models.methodCall so existing callers that
omit or pass an empty model keep legacy behavior while still allowing explicit
model overrides.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 159bc4e0-d67e-40bc-8f40-b78d6b7cbfa7
📒 Files selected for processing (4)
components/odoo/actions/create-record/create-record.mjscomponents/odoo/actions/search-read-records/search-read-records.mjscomponents/odoo/actions/update-record/update-record.mjscomponents/odoo/odoo.app.mjs
- Pass modelName into fields options via options({ modelName }) and propDefinition callback
- Remove unused readRecord helper
- Use plain odoo prop with reloadProps on modelName (create, search-read, update)
- Add predefined model options (res.partner, helpdesk.ticket, sale.order, crm.lead) to modelName prop - Fix promise error handling in getUid() and makeRequest() methods to properly reject on errors - Bump package version from 0.1.1 to 0.2.0 - Bump action versions from 0.0.3 to 0.0.4 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-authored-by: Jorge Cortes <jacortesmahmud@gmail.com>
…s.mjs Co-authored-by: Jorge Cortes <jacortesmahmud@gmail.com>
Co-authored-by: Jorge Cortes <jacortesmahmud@gmail.com>
|
@jcortes i made those versions changes now its ready! |




…ting method signatures. Bump action versions to 0.0.3 for create, search-read, and update record actions. This allows for dynamic model interaction in Odoo API calls.
WHY
Odoo actions were always calling execute_kw with the hardcoded model res.partner, so Create / Update / Search–Read only worked for contacts. This change threads a model argument through the app client and adds a modelName prop (default res.partner) so workflows can target any Odoo model (e.g. sale.order, helpdesk.ticket, crm.lead).
Changes
components/odoo/odoo.app.mjs
makeRequest(model, method, filter, args) — model is no longer hardcoded.
New shared prop definition modelName with default res.partner.
RPC helpers (getFields, searchAndReadRecords, readRecord, createRecord, updateRecord) take model as the first argument.
getFieldProps(model, { update }) loads metadata for the selected model.
fields prop options() uses this.modelName (with fallback to res.partner) so field lists match the model.
Actions (create-record, update-record, search-read-records)
modelName prop via propDefinition, placed before odoo; odoo uses reloadProps: true where dynamic fields depend on the model.
run() passes modelName into the app methods and omits modelName from the record payload sent to Odoo.
Component versions 0.0.2 → 0.0.3.
Backward compatibility
modelName defaults to res.partner, so existing workflows behave as before unless the model is changed.
Action keys and annotations (destructiveHint, openWorldHint, readOnlyHint) are unchanged.
Summary by CodeRabbit