Skip to content

fix(odoo): support dynamic model in actions#20483

Merged
jcortes merged 18 commits intoPipedreamHQ:masterfrom
RoboSourceTeam:fix/odoo-dynamic-model
Apr 14, 2026
Merged

fix(odoo): support dynamic model in actions#20483
jcortes merged 18 commits intoPipedreamHQ:masterfrom
RoboSourceTeam:fix/odoo-dynamic-model

Conversation

@e11man
Copy link
Copy Markdown
Contributor

@e11man e11man commented Apr 1, 2026

…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

  • New Features
    • Odoo actions now support model selection. The create, search, read, and update record actions now allow specifying which Odoo model to work with, providing greater flexibility beyond previous default behavior.

…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.
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
pipedream-docs-redirect-do-not-edit Ignored Ignored Apr 14, 2026 3:25pm

Request Review

@pipedream-component-development
Copy link
Copy Markdown
Collaborator

Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified.

@pipedream-component-development
Copy link
Copy Markdown
Collaborator

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:

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 1, 2026

Walkthrough

The pull request refactors Odoo integration components to support multiple models. A new modelName property was added to the core app and three action files. All method signatures in the app now accept a model parameter instead of defaulting to "res.partner". Action files were updated to pass the model explicitly when calling app methods. All component versions were bumped from 0.0.2 to 0.0.3.

Changes

Cohort / File(s) Summary
Core App Refactoring
components/odoo/odoo.app.mjs
Added modelName propDefinition (default: "res.partner"). Updated makeRequest, getFieldProps, getFields, searchAndReadRecords, readRecord, createRecord, and updateRecord method signatures to accept model as the first parameter. Version bumped to 0.0.3.
Action Updates
components/odoo/actions/create-record/create-record.mjs, components/odoo/actions/search-read-records/search-read-records.mjs, components/odoo/actions/update-record/update-record.mjs
Each action added a new public prop modelName derived from odoo prop. Updated run() and helper methods to destructure and pass modelName when calling odoo methods. Versions bumped to 0.0.3. Search-read-records also added reloadProps: true to odoo prop.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding support for dynamic models in Odoo actions instead of the hardcoded res.partner model.
Description check ✅ Passed The description adequately explains why the change was needed, what was changed, and addresses backward compatibility concerns, though it exceeds the minimal template structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟠 Major

Restore default model fallback in helper methods to keep compatibility.

At Line 53 and Lines 94-107, model became mandatory with no defensive fallback. Any caller that omits model (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

📥 Commits

Reviewing files that changed from the base of the PR and between 1c37cb2 and 9cc2e48.

📒 Files selected for processing (4)
  • components/odoo/actions/create-record/create-record.mjs
  • components/odoo/actions/search-read-records/search-read-records.mjs
  • components/odoo/actions/update-record/update-record.mjs
  • components/odoo/odoo.app.mjs

Copy link
Copy Markdown
Contributor

@jcortes jcortes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @e11man thanks for this great contribution! I've just added a couple of request changes!

Comment thread components/odoo/odoo.app.mjs Outdated
Comment thread components/odoo/odoo.app.mjs Outdated
Comment thread components/odoo/actions/create-record/create-record.mjs
@jcortes jcortes moved this from Ready for PR Review to Changes Required in Component (Source and Action) Backlog Apr 7, 2026
@e11man e11man requested a review from jcortes April 8, 2026 13:18
- 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)
Copy link
Copy Markdown
Contributor

@jcortes jcortes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @e11man please increase the patch version in components/odoo/package.json as well

@jcortes jcortes moved this from Changes Required to Ready for QA in Component (Source and Action) Backlog Apr 9, 2026
@e11man e11man requested a review from jcortes April 10, 2026 13:44
@jcortes jcortes moved this from Ready for QA to In Review in Component (Source and Action) Backlog Apr 10, 2026
@jcortes jcortes moved this from In Review to Ready for QA in Component (Source and Action) Backlog Apr 10, 2026
Copy link
Copy Markdown
Contributor

@jcortes jcortes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @e11man quick question are you able to list props dynamically, I tried but I get this error:

Image

Comment thread components/odoo/odoo.app.mjs
@jcortes jcortes moved this from Ready for QA to Changes Required in Component (Source and Action) Backlog Apr 10, 2026
e11man and others added 2 commits April 13, 2026 10:10
- 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>
@e11man e11man requested a review from jcortes April 13, 2026 14:14
Copy link
Copy Markdown
Contributor

@jcortes jcortes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @e11man I still have this error, do you know if it is due to a setup I'm missing?

Image

@e11man
Copy link
Copy Markdown
Contributor Author

e11man commented Apr 13, 2026

Hi @e11man I still have this error, do you know if it is due to a setup I'm missing?

Image

yea i think it is I have an odoo account set up and it works great for me
Screenshot 2026-04-13 at 1 20 47 PM

@jcortes

@e11man e11man requested a review from jcortes April 13, 2026 17:21
jcortes
jcortes previously approved these changes Apr 14, 2026
Copy link
Copy Markdown
Contributor

@jcortes jcortes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @e11man lgtm! This is ready for release!

Comment thread components/odoo/actions/create-record/create-record.mjs Outdated
Comment thread components/odoo/actions/search-read-records/search-read-records.mjs Outdated
Comment thread components/odoo/actions/update-record/update-record.mjs Outdated
Co-authored-by: Jorge Cortes <jacortesmahmud@gmail.com>
e11man and others added 3 commits April 14, 2026 11:17
@e11man
Copy link
Copy Markdown
Contributor Author

e11man commented Apr 14, 2026

@jcortes i made those versions changes now its ready!

@e11man e11man requested a review from jcortes April 14, 2026 15:18
@jcortes jcortes merged commit 24ae511 into PipedreamHQ:master Apr 14, 2026
9 checks passed
@github-project-automation github-project-automation Bot moved this from Changes Required to Done in Component (Source and Action) Backlog Apr 14, 2026
@e11man e11man deleted the fix/odoo-dynamic-model branch April 14, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

User submitted Submitted by a user

Development

Successfully merging this pull request may close these issues.

5 participants