Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

feat(odoo): let AI agents search, create and update Odoo records, leads, orders, invoices and tasks (#16070)

Odai Ahmadd9a316c93107
diff --git a/bun.lock b/bun.lock
index 04a04421b59..afb7d33cfc3 100644
--- a/bun.lock
+++ b/bun.lock
@@ -6476,7 +6476,7 @@
},
"packages/pieces/community/odoo": {
"name": "@activepieces/piece-odoo",
- "version": "0.2.1",
+ "version": "0.3.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
diff --git a/packages/pieces/community/odoo/package.json b/packages/pieces/community/odoo/package.json
index f2b3a2c8236..4cf6706c50f 100644
--- a/packages/pieces/community/odoo/package.json
+++ b/packages/pieces/community/odoo/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-odoo",
- "version": "0.2.1",
+ "version": "0.3.0",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"dependencies": {
diff --git a/packages/pieces/community/odoo/src/i18n/translation.json b/packages/pieces/community/odoo/src/i18n/translation.json
index fa8bbe7fd11..253509449f2 100644
--- a/packages/pieces/community/odoo/src/i18n/translation.json
+++ b/packages/pieces/community/odoo/src/i18n/translation.json
@@ -26,6 +26,38 @@
"Create Lead or Opportunity": "Create Lead or Opportunity",
"Create Quotation": "Create Quotation",
"Find Invoices": "Find Invoices",
+ "Attach File": "Attach File",
+ "Call Model Method": "Call Model Method",
+ "Confirm Quotation": "Confirm Quotation",
+ "Count Records": "Count Records",
+ "Create Invoice": "Create Invoice",
+ "Create Lead": "Create Lead",
+ "Create Contact": "Create Contact",
+ "Create Product": "Create Product",
+ "Create Record": "Create Record",
+ "Create Task": "Create Task",
+ "Delete Records": "Delete Records",
+ "Download Attachment": "Download Attachment",
+ "Find Leads": "Find Leads",
+ "Find Contacts": "Find Contacts",
+ "Find Products": "Find Products",
+ "Find Sales Orders": "Find Sales Orders",
+ "Find Tasks": "Find Tasks",
+ "Get Connection Info": "Get Connection Info",
+ "Get Model Fields": "Get Model Fields",
+ "Get Records by ID": "Get Records by ID",
+ "List CRM Stages": "List CRM Stages",
+ "List Models": "List Models",
+ "List Projects": "List Projects",
+ "List Record Attachments": "List Record Attachments",
+ "List Users": "List Users",
+ "Mark Lead Lost": "Mark Lead Lost",
+ "Mark Lead Won": "Mark Lead Won",
+ "Find ID by Name": "Find ID by Name",
+ "Post Invoice": "Post Invoice",
+ "Post Message on Record": "Post Message on Record",
+ "Search Records": "Search Records",
+ "Update Records": "Update Records",
"Get contacts on Odoo": "Get contacts on Odoo",
"Create/Update contact on Odoo": "Create/Update contact on Odoo",
"Create/Update company on Odoo": "Create/Update company on Odoo",
@@ -41,6 +73,39 @@
"Create a lead or opportunity in Odoo CRM.": "Create a lead or opportunity in Odoo CRM.",
"Create a quotation (draft sales order) with order lines.": "Create a quotation (draft sales order) with order lines.",
"List invoices, bills and credit notes, filtered by type, status, customer and dates.": "List invoices, bills and credit notes, filtered by type, status, customer and dates.",
+ "Attach a file to an Odoo record.": "Attach a file to an Odoo record.",
+ "Call a public method of an Odoo model, for example a button action.": "Call a public method of an Odoo model, for example a button action.",
+ "Confirm an Odoo quotation into a sales order.": "Confirm an Odoo quotation into a sales order.",
+ "Count the records of an Odoo model that match a domain.": "Count the records of an Odoo model that match a domain.",
+ "Create a draft customer invoice, vendor bill or credit note in Odoo.": "Create a draft customer invoice, vendor bill or credit note in Odoo.",
+ "Create a contact person or company in Odoo.": "Create a contact person or company in Odoo.",
+ "Create a product in Odoo.": "Create a product in Odoo.",
+ "Create a record in any Odoo model from a JSON object of field values.": "Create a record in any Odoo model from a JSON object of field values.",
+ "Create a draft sales order (quotation) in Odoo.": "Create a draft sales order (quotation) in Odoo.",
+ "Create a task in an Odoo project.": "Create a task in an Odoo project.",
+ "Permanently delete records of any Odoo model.": "Permanently delete records of any Odoo model.",
+ "Download an Odoo attachment as a file.": "Download an Odoo attachment as a file.",
+ "Search Odoo invoices, bills and credit notes.": "Search Odoo invoices, bills and credit notes.",
+ "Search Odoo CRM leads and opportunities.": "Search Odoo CRM leads and opportunities.",
+ "Search Odoo contacts and companies.": "Search Odoo contacts and companies.",
+ "Search Odoo products.": "Search Odoo products.",
+ "Search Odoo quotations and sales orders.": "Search Odoo quotations and sales orders.",
+ "Search Odoo project tasks.": "Search Odoo project tasks.",
+ "Get the Odoo version, the connected user and which apps can be used.": "Get the Odoo version, the connected user and which apps can be used.",
+ "List the fields of an Odoo model with their type, whether they are required, and allowed values.": "List the fields of an Odoo model with their type, whether they are required, and allowed values.",
+ "Read one or more records of any Odoo model by ID.": "Read one or more records of any Odoo model by ID.",
+ "List the pipeline stages of Odoo CRM.": "List the pipeline stages of Odoo CRM.",
+ "Find the technical name of an Odoo model, for example \"invoice\" → account.move.": "Find the technical name of an Odoo model, for example \"invoice\" → account.move.",
+ "List Odoo projects.": "List Odoo projects.",
+ "List the files attached to an Odoo record.": "List the files attached to an Odoo record.",
+ "List internal Odoo users (salespeople, assignees).": "List internal Odoo users (salespeople, assignees).",
+ "Mark an Odoo CRM lead or opportunity as lost.": "Mark an Odoo CRM lead or opportunity as lost.",
+ "Mark an Odoo CRM opportunity as won.": "Mark an Odoo CRM opportunity as won.",
+ "Find record IDs by name, like typing in an Odoo selection field.": "Find record IDs by name, like typing in an Odoo selection field.",
+ "Validate (post) a draft Odoo invoice so it gets its number.": "Validate (post) a draft Odoo invoice so it gets its number.",
+ "Post an internal note or a message in the chatter of an Odoo record.": "Post an internal note or a message in the chatter of an Odoo record.",
+ "Search any Odoo model with a domain and return the chosen fields.": "Search any Odoo model with a domain and return the chosen fields.",
+ "Set field values on one or more records of any Odoo model.": "Set field values on one or more records of any Odoo model.",
"Type": "Type",
"Contact Name": "Contact Name",
"Contact Phone": "Contact Phone",
@@ -87,6 +152,76 @@
"Invoice Date To": "Invoice Date To",
"Due Date From": "Due Date From",
"Due Date To": "Due Date To",
+ "MIME Type": "MIME Type",
+ "Record IDs": "Record IDs",
+ "Extra Positional Arguments": "Extra Positional Arguments",
+ "Keyword Arguments": "Keyword Arguments",
+ "Order ID": "Order ID",
+ "Domain": "Domain",
+ "Partner ID": "Partner ID",
+ "Lines": "Lines",
+ "Invoice Date": "Invoice Date",
+ "Due Date": "Due Date",
+ "Reference": "Reference",
+ "Customer ID": "Customer ID",
+ "Probability": "Probability",
+ "Stage ID": "Stage ID",
+ "Salesperson User ID": "Salesperson User ID",
+ "Sales Team ID": "Sales Team ID",
+ "Tag IDs": "Tag IDs",
+ "Priority": "Priority",
+ "Name": "Name",
+ "Is a Company": "Is a Company",
+ "Parent Company ID": "Parent Company ID",
+ "Job Position": "Job Position",
+ "Website": "Website",
+ "Tax ID": "Tax ID",
+ "Internal Reference": "Internal Reference",
+ "Street": "Street",
+ "Street 2": "Street 2",
+ "City": "City",
+ "ZIP": "ZIP",
+ "Country Code": "Country Code",
+ "Customer Rank": "Customer Rank",
+ "Supplier Rank": "Supplier Rank",
+ "Kind": "Kind",
+ "Sales Price": "Sales Price",
+ "Cost": "Cost",
+ "Barcode": "Barcode",
+ "Can Be Sold": "Can Be Sold",
+ "Can Be Purchased": "Can Be Purchased",
+ "Values": "Values",
+ "Project ID": "Project ID",
+ "Description": "Description",
+ "Assignee User IDs": "Assignee User IDs",
+ "Deadline": "Deadline",
+ "Parent Task ID": "Parent Task ID",
+ "Attachment ID": "Attachment ID",
+ "Types": "Types",
+ "Payment Statuses": "Payment Statuses",
+ "Search Text": "Search Text",
+ "Created After": "Created After",
+ "Include Lost": "Include Lost",
+ "Email (exact)": "Email (exact)",
+ "Companies Only": "Companies Only",
+ "Include Archived": "Include Archived",
+ "Sellable Only": "Sellable Only",
+ "Reference Contains": "Reference Contains",
+ "Order Date From": "Order Date From",
+ "Order Date To": "Order Date To",
+ "Assignee User ID": "Assignee User ID",
+ "Title Contains": "Title Contains",
+ "Only These Fields": "Only These Fields",
+ "Required Fields Only": "Required Fields Only",
+ "Search": "Search",
+ "Name Contains": "Name Contains",
+ "Lead ID": "Lead ID",
+ "Lost Reason ID": "Lost Reason ID",
+ "Match": "Match",
+ "Invoice ID": "Invoice ID",
+ "Body": "Body",
+ "Also Notify Partner IDs": "Also Notify Partner IDs",
+ "Order": "Order",
"Select which contact type to get": "Select which contact type to get",
"Would you like to search any specific name?": "Would you like to search any specific name?",
"Model name. e.g.: res.partner": "Model name. e.g.: res.partner",
@@ -117,12 +252,137 @@
"Optional. Includes invoices of its contacts.": "Optional. Includes invoices of its contacts.",
"Default 50, maximum 500.": "Default 50, maximum 500.",
"Skip this many invoices (for paging).": "Skip this many invoices (for paging).",
+ "Technical model name, for example res.partner (contacts), crm.lead, sale.order, account.move (invoices), product.product, project.task. Resolve unknown names with odoo_list_models.": "Technical model name, for example res.partner (contacts), crm.lead, sale.order, account.move (invoices), product.product, project.task. Resolve unknown names with odoo_list_models.",
+ "ID of the record to attach the file to.": "ID of the record to attach the file to.",
+ "A file URL or base64 content.": "A file URL or base64 content.",
+ "For example contract.pdf. Defaults to the source name.": "For example contract.pdf. Defaults to the source name.",
+ "For example application/pdf. Odoo guesses it when empty.": "For example application/pdf. Odoo guesses it when empty.",
+ "Public method name, for example action_archive. Private (_) and generic CRUD methods such as unlink or write are refused.": "Public method name, for example action_archive. Private (_) and generic CRUD methods such as unlink or write are refused.",
+ "Records to call the method on, for example [12]. Leave empty for model-level methods such as default_get.": "Records to call the method on, for example [12]. Leave empty for model-level methods such as default_get.",
+ "JSON list passed after the record IDs, for example [[\"name\", \"email\"]] for default_get. Usually empty.": "JSON list passed after the record IDs, for example [[\"name\", \"email\"]] for default_get. Usually empty.",
+ "JSON object of named arguments, for example {\"partner_ids\": [7]} for message_subscribe.": "JSON object of named arguments, for example {\"partner_ids\": [7]} for message_subscribe.",
+ "sale.order ID.": "sale.order ID.",
+ "Odoo domain: a JSON list of [field, operator, value] conditions, ANDed together; use \"|\" before two conditions for OR. Example [[\"is_company\", \"=\", true], [\"country_id.code\", \"=\", \"US\"]]. Empty = all records.": "Odoo domain: a JSON list of [field, operator, value] conditions, ANDed together; use \"|\" before two conditions for OR. Example [[\"is_company\", \"=\", true], [\"country_id.code\", \"=\", \"US\"]]. Empty = all records.",
+ "out_invoice (default), in_invoice (vendor bill), out_refund, in_refund.": "out_invoice (default), in_invoice (vendor bill), out_refund, in_refund.",
+ "Customer or vendor res.partner ID.": "Customer or vendor res.partner ID.",
+ "JSON list, for example [{\"product\": 12, \"quantity\": 2}, {\"description\": \"Consulting\", \"quantity\": 3, \"price_unit\": 150, \"tax_ids\": [1]}]. Omit tax_ids to use the product default taxes.": "JSON list, for example [{\"product\": 12, \"quantity\": 2}, {\"description\": \"Consulting\", \"quantity\": 3, \"price_unit\": 150, \"tax_ids\": [1]}]. Omit tax_ids to use the product default taxes.",
+ "Date, for example 2026-09-29. Omit to set it when posting.": "Date, for example 2026-09-29. Omit to set it when posting.",
+ "Date. Omit to use the payment terms.": "Date. Omit to use the payment terms.",
+ "Customer reference or vendor bill number.": "Customer reference or vendor bill number.",
+ "opportunity (default) or lead.": "opportunity (default) or lead.",
+ "res.partner ID from odoo_find_partners.": "res.partner ID from odoo_find_partners.",
+ "Person to talk to.": "Person to talk to.",
+ "Company name when there is no customer ID yet.": "Company name when there is no customer ID yet.",
+ "Contact email.": "Contact email.",
+ "Contact phone.": "Contact phone.",
+ "In the company currency.": "In the company currency.",
+ "0 to 100. Omit to let Odoo compute it.": "0 to 100. Omit to let Odoo compute it.",
+ "crm.stage ID from odoo_list_crm_stages. Omit for the first stage.": "crm.stage ID from odoo_list_crm_stages. Omit for the first stage.",
+ "res.users ID from odoo_list_users. Omit for the connected user.": "res.users ID from odoo_list_users. Omit for the connected user.",
+ "crm.team ID.": "crm.team ID.",
+ "crm.tag IDs, for example [1, 3]. Resolve names with odoo_name_search on crm.tag.": "crm.tag IDs, for example [1, 3]. Resolve names with odoo_name_search on crm.tag.",
+ "\"0\" normal to \"3\" very high.": "\"0\" normal to \"3\" very high.",
+ "Date, for example 2026-10-31.": "Date, for example 2026-10-31.",
+ "Internal notes.": "Internal notes.",
+ "Full name of the person or company.": "Full name of the person or company.",
+ "true for a company, false or omitted for a person.": "true for a company, false or omitted for a person.",
+ "For a person: the ID of the company they work for.": "For a person: the ID of the company they work for.",
+ "For example [email protected]": "For example [email protected]",
+ "For example +1 555 0100": "For example +1 555 0100",
+ "For example Buyer": "For example Buyer",
+ "For example https://acme.example": "For example https://acme.example",
+ "VAT or tax number": "VAT or tax number",
+ "Your own code for this contact": "Your own code for this contact",
+ "Street and number": "Street and number",
+ "Second address line": "Second address line",
+ "Postal code": "Postal code",
+ "Two-letter ISO code, for example US": "Two-letter ISO code, for example US",
+ "Needs Invoicing. Set 1 to mark as a customer.": "Needs Invoicing. Set 1 to mark as a customer.",
+ "Needs Invoicing. Set 1 to mark as a vendor.": "Needs Invoicing. Set 1 to mark as a vendor.",
+ "Product name.": "Product name.",
+ "goods (default), service, or storable (inventory-tracked goods).": "goods (default), service, or storable (inventory-tracked goods).",
+ "Unit sales price.": "Unit sales price.",
+ "Unit cost.": "Unit cost.",
+ "For example FURN_7800.": "For example FURN_7800.",
+ "Must be unique in Odoo.": "Must be unique in Odoo.",
+ "Default true in Odoo.": "Default true in Odoo.",
+ "JSON object of field values, for example {\"name\": \"Acme\", \"is_company\": true}. Many2one fields take an ID. Many2many/one2many fields take command lists: [[6, 0, [3, 4]]] replaces with IDs 3 and 4, [[4, 7]] adds ID 7, [[0, 0, {\"name\": \"line\"}]] creates a line.": "JSON object of field values, for example {\"name\": \"Acme\", \"is_company\": true}. Many2one fields take an ID. Many2many/one2many fields take command lists: [[6, 0, [3, 4]]] replaces with IDs 3 and 4, [[4, 7]] adds ID 7, [[0, 0, {\"name\": \"line\"}]] creates a line.",
+ "JSON list of lines, for example [{\"product\": 12, \"quantity\": 2}, {\"product\": \"FURN_7800\", \"quantity\": 1, \"price_unit\": 99.5, \"description\": \"Custom desk\"}]. product = product.product ID or internal reference.": "JSON list of lines, for example [{\"product\": 12, \"quantity\": 2}, {\"product\": \"FURN_7800\", \"quantity\": 1, \"price_unit\": 99.5, \"description\": \"Custom desk\"}]. product = product.product ID or internal reference.",
+ "For example the customer PO number.": "For example the customer PO number.",
+ "res.users ID. Omit for the connected user.": "res.users ID. Omit for the connected user.",
+ "project.project ID from odoo_list_projects.": "project.project ID from odoo_list_projects.",
+ "Task title.": "Task title.",
+ "Task description (plain text or simple HTML).": "Task description (plain text or simple HTML).",
+ "res.users IDs from odoo_list_users, for example [2].": "res.users IDs from odoo_list_users, for example [2].",
+ "Date, for example 2026-10-15.": "Date, for example 2026-10-15.",
+ "project.tags IDs.": "project.tags IDs.",
+ "\"0\" normal (default) or \"1\" high.": "\"0\" normal (default) or \"1\" high.",
+ "res.partner ID.": "res.partner ID.",
+ "Create as a sub-task of this task.": "Create as a sub-task of this task.",
+ "IDs of the records to delete, for example [12]. At most 100.": "IDs of the records to delete, for example [12]. At most 100.",
+ "From odoo_list_record_attachments.": "From odoo_list_record_attachments.",
+ "Any of out_invoice, in_invoice, out_refund, in_refund. Omit for all four.": "Any of out_invoice, in_invoice, out_refund, in_refund. Omit for all four.",
+ "draft, posted or cancel. Omit for all.": "draft, posted or cancel. Omit for all.",
+ "Any of not_paid, partial, in_payment, paid, reversed (blocked on 18+). For unpaid use [\"not_paid\", \"partial\"].": "Any of not_paid, partial, in_payment, paid, reversed (blocked on 18+). For unpaid use [\"not_paid\", \"partial\"].",
+ "res.partner ID; includes its contacts.": "res.partner ID; includes its contacts.",
+ "For example INV/2026/0007.": "For example INV/2026/0007.",
+ "Date, for example 2026-09-01.": "Date, for example 2026-09-01.",
+ "Date.": "Date.",
+ "Date. For overdue invoices use yesterday.": "Date. For overdue invoices use yesterday.",
+ "Maximum records to return. Default 50, maximum 500. Check has_more and pass next_offset as offset for the next page.": "Maximum records to return. Default 50, maximum 500. Check has_more and pass next_offset as offset for the next page.",
+ "Number of records to skip, for paging. Use next_offset from the previous call.": "Number of records to skip, for paging. Use next_offset from the previous call.",
+ "Matches title, contact name, company name or email.": "Matches title, contact name, company name or email.",
+ "Omit for both.": "Omit for both.",
+ "crm.stage ID.": "crm.stage ID.",
+ "res.users ID.": "res.users ID.",
+ "ISO date or datetime, for example 2026-09-01 or 2026-09-01T08:00:00Z (UTC when no zone).": "ISO date or datetime, for example 2026-09-01 or 2026-09-01T08:00:00Z (UTC when no zone).",
+ "Also return lost (archived) leads.": "Also return lost (archived) leads.",
+ "Matches name, email, phone or internal reference (contains, any case).": "Matches name, email, phone or internal reference (contains, any case).",
+ "Exact email address, any case.": "Exact email address, any case.",
+ "true = only companies, false = only people. Omit for both.": "true = only companies, false = only people. Omit for both.",
+ "Only contacts that belong to this company.": "Only contacts that belong to this company.",
+ "Two-letter ISO code, for example US or BE.": "Two-letter ISO code, for example US or BE.",
+ "Also return archived contacts.": "Also return archived contacts.",
+ "Matches name, internal reference or barcode (contains).": "Matches name, internal reference or barcode (contains).",
+ "Only products that can be sold.": "Only products that can be sold.",
+ "draft = quotation, sent = quotation sent, sale = sales order, cancel = cancelled (done = locked, Odoo 16 only). Omit for all.": "draft = quotation, sent = quotation sent, sale = sales order, cancel = cancelled (done = locked, Odoo 16 only). Omit for all.",
+ "res.partner ID; includes orders of its contacts.": "res.partner ID; includes orders of its contacts.",
+ "Matches the order number (S00012) or the customer reference.": "Matches the order number (S00012) or the customer reference.",
+ "ISO date or datetime (UTC when no zone).": "ISO date or datetime (UTC when no zone).",
+ "ISO date or datetime (UTC when no zone). A date alone includes that whole day.": "ISO date or datetime (UTC when no zone). A date alone includes that whole day.",
+ "project.project ID.": "project.project ID.",
+ "Tasks assigned to this res.users ID.": "Tasks assigned to this res.users ID.",
+ "project.task.type ID.": "project.task.type ID.",
+ "Part of the task title.": "Part of the task title.",
+ "Optional list of field names to describe, for example [\"partner_id\", \"state\"]. Empty = all fields.": "Optional list of field names to describe, for example [\"partner_id\", \"state\"]. Empty = all fields.",
+ "Only return fields that must be set when creating a record.": "Only return fields that must be set when creating a record.",
+ "Record IDs, for example [12, 15]. At most 500.": "Record IDs, for example [12, 15]. At most 500.",
+ "Field names to return, for example [\"name\", \"email\", \"partner_id\"]. Leave empty for every field except binary ones (files, images). Get names from odoo_get_model_fields.": "Field names to return, for example [\"name\", \"email\", \"partner_id\"]. Leave empty for every field except binary ones (files, images). Get names from odoo_get_model_fields.",
+ "Only stages used by this team, plus shared ones.": "Only stages used by this team, plus shared ones.",
+ "Maximum records to return. Default 100, maximum 500. Check has_more and pass next_offset as offset for the next page.": "Maximum records to return. Default 100, maximum 500. Check has_more and pass next_offset as offset for the next page.",
+ "Part of the model name or description, for example \"lead\", \"invoice\" or \"sale\". Empty = all models.": "Part of the model name or description, for example \"lead\", \"invoice\" or \"sale\". Empty = all models.",
+ "Part of the project name.": "Part of the project name.",
+ "ID of the record whose attachments to list.": "ID of the record whose attachments to list.",
+ "Maximum records to return. Default 50, maximum 200. Check has_more and pass next_offset as offset for the next page.": "Maximum records to return. Default 50, maximum 200. Check has_more and pass next_offset as offset for the next page.",
+ "Matches name, login or email (contains).": "Matches name, login or email (contains).",
+ "crm.lead ID from odoo_find_leads.": "crm.lead ID from odoo_find_leads.",
+ "crm.lost.reason ID. Resolve with odoo_name_search on crm.lost.reason.": "crm.lost.reason ID. Resolve with odoo_name_search on crm.lost.reason.",
+ "Text to match, for example \"Acme\". Empty = first records.": "Text to match, for example \"Acme\". Empty = first records.",
+ "ilike = contains (default), = = exact name.": "ilike = contains (default), = = exact name.",
+ "Maximum records to return. Default 10, maximum 100. Check has_more and pass next_offset as offset for the next page.": "Maximum records to return. Default 10, maximum 100. Check has_more and pass next_offset as offset for the next page.",
+ "account.move ID from odoo_create_invoice or odoo_find_invoices.": "account.move ID from odoo_create_invoice or odoo_find_invoices.",
+ "ID of the record to post on.": "ID of the record to post on.",
+ "Plain text of the message. HTML tags are shown as text.": "Plain text of the message. HTML tags are shown as text.",
+ "note = internal note (default). message = sent to followers by email.": "note = internal note (default). message = sent to followers by email.",
+ "Contact IDs (res.partner) to notify in addition to followers, for example [7]. Only used with kind \"message\".": "Contact IDs (res.partner) to notify in addition to followers, for example [7]. Only used with kind \"message\".",
+ "Sort, for example \"create_date desc, id desc\". Empty = the model default order.": "Sort, for example \"create_date desc, id desc\". Empty = the model default order.",
+ "IDs of the records to update, for example [12]. At most 500.": "IDs of the records to update, for example [12]. At most 500.",
+ "JSON object with only the fields to change, for example {\"phone\": \"+1 555 0100\"}. Same value format as odoo_create_record (IDs for many2one, command lists for many2many).": "JSON object with only the fields to change, for example {\"phone\": \"+1 555 0100\"}. Same value format as odoo_create_record (IDs for many2one, command lists for many2many).",
"Contact": "Contact",
"Company": "Company",
"Read": "Read",
"Search read": "Search read",
"Search count": "Search count",
- "Search": "Search",
"Create": "Create",
"Write": "Write",
"Unlink": "Unlink",
@@ -143,6 +403,20 @@
"In payment": "In payment",
"Paid": "Paid",
"Reversed": "Reversed",
+ "Normal": "Normal",
+ "Medium": "Medium",
+ "High": "High",
+ "Very high": "Very high",
+ "Goods": "Goods",
+ "Service": "Service",
+ "Storable goods": "Storable goods",
+ "Quotation": "Quotation",
+ "Quotation sent": "Quotation sent",
+ "Sales order": "Sales order",
+ "Locked (Odoo 16)": "Locked (Odoo 16)",
+ "Contains": "Contains",
+ "Exact": "Exact",
+ "Exact, any case": "Exact, any case",
"New Record": "New Record",
"New or Updated Record": "New or Updated Record",
"New Contact": "New Contact",
diff --git a/packages/pieces/community/odoo/src/index.ts b/packages/pieces/community/odoo/src/index.ts
index f33322504b7..ac56c29b612 100644
--- a/packages/pieces/community/odoo/src/index.ts
+++ b/packages/pieces/community/odoo/src/index.ts
@@ -1,5 +1,6 @@
import { createPiece } from '@activepieces/pieces-framework';
import actions from './lib/actions';
+import { odooAtomics } from './lib/actions/atomics';
import { odooAuth } from './lib/auth';
import { newContactTrigger } from './lib/triggers/new-contact';
import { newLeadTrigger } from './lib/triggers/new-lead';
@@ -11,10 +12,10 @@ export const odoo = createPiece({
displayName: 'Odoo',
description: 'Open source all-in-one management software',
auth: odooAuth,
- minimumSupportedRelease: '0.30.0',
+ minimumSupportedRelease: '0.88.2',
logoUrl: 'https://cdn.activepieces.com/pieces/odoo.png',
authors: ["mariomeyer","kishanprmr","abuaboud"],
- actions,
+ actions: [...actions, ...odooAtomics],
triggers: [
newRecordTrigger,
newOrUpdatedRecordTrigger,
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/attach-file.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/attach-file.ts
new file mode 100644
index 00000000000..b1cbe49f718
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/attach-file.ts
@@ -0,0 +1,41 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooOperations } from '../../common/operations';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooAttachFile = createAction({
+ auth: odooAuth,
+ name: 'odoo_attach_file',
+ classification: 'WRITE',
+ displayName: 'Attach File',
+ description: 'Attach a file to an Odoo record.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Uploads a file (URL or base64) as an Odoo attachment (ir.attachment) linked to one record, for example a PDF on a sale order or invoice. Not idempotent: each call adds another attachment. If read_back_error is set, the record was created but could not be read back: do not create it again; read it with odoo_get_records using the returned id.',
+ idempotent: false,
+ },
+ outputSchema: atomicSchemas.createdAttachment,
+ props: {
+ model: atomicProps.modelProp(),
+ record_id: atomicProps.idProp({ displayName: 'Record ID', description: 'ID of the record to attach the file to.' }),
+ file: Property.File({ displayName: 'File', description: 'A file URL or base64 content.', required: true }),
+ file_name: Property.ShortText({ displayName: 'File Name', description: 'For example contract.pdf. Defaults to the source name.', required: false }),
+ mimetype: Property.ShortText({ displayName: 'MIME Type', description: 'For example application/pdf. Odoo guesses it when empty.', required: false }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ return odooOperations.attachFile({
+ client,
+ model: odooInput.toModelName(p.model),
+ recordId: odooInput.toId({ value: p.record_id, label: 'Record ID' }),
+ file: p.file,
+ name: odooInput.optionalText(p.file_name),
+ mimetype: odooInput.optionalText(p.mimetype),
+ });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/call-method.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/call-method.ts
new file mode 100644
index 00000000000..49b2b478103
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/call-method.ts
@@ -0,0 +1,64 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooOperations } from '../../common/operations';
+import { odooInput } from '../../common/values';
+import { runMethodOutputSchema } from '../../output-schemas';
+import { atomicProps } from './common';
+
+export const odooCallMethod = createAction({
+ auth: odooAuth,
+ name: 'odoo_call_method',
+ classification: 'WRITE',
+ displayName: 'Call Model Method',
+ description: 'Call a public method of an Odoo model, for example a button action.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Calls any public Odoo model method (execute_kw) on the given record IDs with extra positional and keyword arguments, for business verbs without a dedicated action, for example action_archive, action_unarchive, message_subscribe, action_cancel. A method that returns nothing is reported as success with returned_none true. unlink, write, update, create, name_create, load, web_save, copy, browse, sudo, with_user, with_context, with_env and private (_) methods are refused: use odoo_delete_records, odoo_update_records, odoo_create_record or odoo_get_records instead. This list steers you to the right action; it is not a security boundary, and Odoo access rights of the connected user still decide what the call may do. Not idempotent in general; depends on the method.',
+ idempotent: false,
+ },
+ outputSchema: runMethodOutputSchema,
+ props: {
+ model: atomicProps.modelProp(),
+ method: Property.ShortText({
+ displayName: 'Method',
+ description: 'Public method name, for example action_archive. Private (_) and generic CRUD methods such as unlink or write are refused.',
+ required: true,
+ }),
+ ids: Property.Array({
+ displayName: 'Record IDs',
+ description: 'Records to call the method on, for example [12]. Leave empty for model-level methods such as default_get.',
+ required: false,
+ }),
+ args: Property.Json({
+ displayName: 'Extra Positional Arguments',
+ description: 'JSON list passed after the record IDs, for example [["name", "email"]] for default_get. Usually empty.',
+ required: false,
+ }),
+ kwargs: Property.Json({
+ displayName: 'Keyword Arguments',
+ description: 'JSON object of named arguments, for example {"partner_ids": [7]} for message_subscribe.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ return odooOperations.runMethod({
+ client,
+ model: odooInput.toModelName(p.model),
+ method: odooInput.toMethodName({ value: p.method, actions: AI_ACTIONS }),
+ ids: odooInput.toIdList({ value: p.ids, label: 'Record IDs', allowEmpty: true }),
+ args: odooInput.parseArray({ value: p.args, label: 'Extra Positional Arguments' }),
+ kwargs: odooInput.parseObject({ value: p.kwargs, label: 'Keyword Arguments', allowEmpty: true }),
+ });
+ },
+});
+
+const AI_ACTIONS = {
+ delete: 'Delete Records (odoo_delete_records)',
+ update: 'Update Records (odoo_update_records)',
+ create: 'Create Record (odoo_create_record)',
+ read: 'Get Records by ID (odoo_get_records)',
+};
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/common.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/common.ts
new file mode 100644
index 00000000000..286181ad757
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/common.ts
@@ -0,0 +1,73 @@
+import { Property } from '@activepieces/pieces-framework';
+
+function modelProp({ description }: { description?: string } = {}) {
+ return Property.ShortText({
+ displayName: 'Model',
+ description:
+ description ??
+ 'Technical model name, for example res.partner (contacts), crm.lead, sale.order, account.move (invoices), product.product, project.task. Resolve unknown names with odoo_list_models.',
+ required: true,
+ });
+}
+
+function idProp({ displayName, description }: { displayName: string; description: string }) {
+ return Property.Number({ displayName, description, required: true });
+}
+
+function optionalIdProp({ displayName, description }: { displayName: string; description: string }) {
+ return Property.Number({ displayName, description, required: false });
+}
+
+function idsProp({ displayName = 'Record IDs', description }: { displayName?: string; description: string }) {
+ return Property.Array({ displayName, description, required: true });
+}
+
+function fieldsProp() {
+ return Property.Array({
+ displayName: 'Fields',
+ description:
+ 'Field names to return, for example ["name", "email", "partner_id"]. Leave empty for every field except binary ones (files, images). Get names from odoo_get_model_fields.',
+ required: false,
+ });
+}
+
+function domainProp() {
+ return Property.Json({
+ displayName: 'Domain',
+ description:
+ 'Odoo domain: a JSON list of [field, operator, value] conditions, ANDed together; use "|" before two conditions for OR. Example [["is_company", "=", true], ["country_id.code", "=", "US"]]. Empty = all records.',
+ required: false,
+ });
+}
+
+function limitProp({ fallback, max }: { fallback: number; max: number }) {
+ return Property.Number({
+ displayName: 'Limit',
+ description: `Maximum records to return. Default ${fallback}, maximum ${max}. Check has_more and pass next_offset as offset for the next page.`,
+ required: false,
+ });
+}
+
+function offsetProp() {
+ return Property.Number({
+ displayName: 'Offset',
+ description: 'Number of records to skip, for paging. Use next_offset from the previous call.',
+ required: false,
+ });
+}
+
+function textProp({ displayName, description, required = false }: { displayName: string; description: string; required?: boolean }) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+export const atomicProps = {
+ modelProp,
+ idProp,
+ optionalIdProp,
+ idsProp,
+ fieldsProp,
+ domainProp,
+ limitProp,
+ offsetProp,
+ textProp,
+};
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/confirm-sale-order.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/confirm-sale-order.ts
new file mode 100644
index 00000000000..e58462396ac
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/confirm-sale-order.ts
@@ -0,0 +1,32 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooConfirmSaleOrder = createAction({
+ auth: odooAuth,
+ name: 'odoo_confirm_sale_order',
+ classification: 'WRITE',
+ displayName: 'Confirm Quotation',
+ description: 'Confirm an Odoo quotation into a sales order.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Confirms one Odoo quotation into a sales order (action_confirm), which can create deliveries and lock pricing. Only draft or sent quotations can be confirmed. Needs the Sales app. Not idempotent: a second call fails because the order is no longer a quotation.',
+ idempotent: false,
+ },
+ outputSchema: atomicSchemas.saleOrder,
+ props: {
+ order_id: atomicProps.idProp({ displayName: 'Order ID', description: 'sale.order ID.' }),
+ },
+ async run(context) {
+ const id = odooInput.toId({ value: context.propsValue.order_id, label: 'Order ID' });
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ await client.callAllowNone({ model: odooApps.saleOrder.model, method: 'action_confirm', args: [[id]] });
+ return odooRecords.readApp({ client, model: odooApps.saleOrder.model, id, wanted: odooApps.saleOrder.fields, manyToOne: odooApps.saleOrder.manyToOne });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/count-records.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/count-records.ts
new file mode 100644
index 00000000000..374884d2493
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/count-records.ts
@@ -0,0 +1,32 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooDomain, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooCountRecords = createAction({
+ auth: odooAuth,
+ name: 'odoo_count_records',
+ classification: 'SEARCH',
+ displayName: 'Count Records',
+ description: 'Count the records of an Odoo model that match a domain.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Counts records of any Odoo model matching an Odoo domain (search_count) without reading them. Use for totals, since search results are paged. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.count,
+ props: {
+ model: atomicProps.modelProp(),
+ domain: atomicProps.domainProp(),
+ },
+ async run(context) {
+ const model = odooInput.toModelName(context.propsValue.model);
+ const domain = odooDomain.parseDomain({ value: context.propsValue.domain });
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const count = await client.call<number>({ model, method: 'search_count', args: [domain] });
+ return { model, count };
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/create-invoice.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/create-invoice.ts
new file mode 100644
index 00000000000..8584ee05472
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/create-invoice.ts
@@ -0,0 +1,104 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooOperations } from '../../common/operations';
+import { odooRecords } from '../../common/records';
+import { odooDates, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+function toLineRecord({ line, index }: { line: unknown; index: number }): Record<string, unknown> {
+ if (!odooInput.isRecord(line)) throw new Error(`Line ${index + 1} must be an object.`);
+ if (!hasProduct(line) && !odooInput.optionalText(line['description'])) throw new Error(`Line ${index + 1} needs a product or a description.`);
+ return line;
+}
+
+function hasProduct(line: Record<string, unknown>): boolean {
+ const product = line['product'];
+ return product !== undefined && product !== null && product !== '';
+}
+
+async function resolveLineProducts({ client, lines }: { client: OdooClient; lines: Record<string, unknown>[] }): Promise<(number | undefined)[]> {
+ const withProduct = lines.flatMap((line, index) => (hasProduct(line) ? [{ index, ref: { value: line['product'], label: `Line ${index + 1} product` } }] : []));
+ const ids = await odooOperations.resolveProducts({ client, refs: withProduct.map((entry) => entry.ref) });
+ const byLine = new Map(withProduct.map((entry, position) => [entry.index, ids[position]]));
+ return lines.map((_, index) => byLine.get(index));
+}
+
+function toInvoiceLine({ line, index, productId }: { line: Record<string, unknown>; index: number; productId: number | undefined }) {
+ const label = `Line ${index + 1}`;
+ const name = odooInput.optionalText(line['description']);
+ const taxIds = line['tax_ids'] === undefined ? undefined : odooInput.toIdList({ value: line['tax_ids'], label: `${label} tax_ids`, allowEmpty: true });
+ return [
+ 0,
+ 0,
+ odooInput.definedOnly({
+ product_id: productId,
+ name,
+ quantity: odooInput.toOptionalNumber({ value: line['quantity'], label: `${label} quantity` }) ?? 1,
+ price_unit: odooInput.toOptionalNumber({ value: line['price_unit'], label: `${label} price_unit` }),
+ tax_ids: taxIds === undefined ? undefined : [[6, 0, taxIds]],
+ }),
+ ];
+}
+
+export const odooCreateInvoice = createAction({
+ auth: odooAuth,
+ name: 'odoo_create_invoice',
+ classification: 'WRITE',
+ displayName: 'Create Invoice',
+ description: 'Create a draft customer invoice, vendor bill or credit note in Odoo.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates a draft Odoo invoice (account.move): customer invoice (default), vendor bill or credit note, for a partner with up to 200 lines (product ID/reference and/or description, quantity, unit price, optional tax IDs). Post it with odoo_post_invoice. Needs Invoicing. Not idempotent: each call creates a new draft. If read_back_error is set, the record was created but could not be read back: do not create it again; read it with odoo_get_records using the returned id.',
+ idempotent: false,
+ },
+ outputSchema: atomicSchemas.createdInvoice,
+ props: {
+ move_type: Property.StaticDropdown({
+ displayName: 'Type',
+ description: 'out_invoice (default), in_invoice (vendor bill), out_refund, in_refund.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Customer invoice', value: 'out_invoice' },
+ { label: 'Vendor bill', value: 'in_invoice' },
+ { label: 'Customer credit note', value: 'out_refund' },
+ { label: 'Vendor refund', value: 'in_refund' },
+ ],
+ },
+ }),
+ partner_id: atomicProps.idProp({ displayName: 'Partner ID', description: 'Customer or vendor res.partner ID.' }),
+ lines: Property.Json({
+ displayName: 'Lines',
+ description:
+ 'JSON list, for example [{"product": 12, "quantity": 2}, {"description": "Consulting", "quantity": 3, "price_unit": 150, "tax_ids": [1]}]. Omit tax_ids to use the product default taxes.',
+ required: true,
+ }),
+ invoice_date: atomicProps.textProp({ displayName: 'Invoice Date', description: 'Date, for example 2026-09-29. Omit to set it when posting.' }),
+ invoice_date_due: atomicProps.textProp({ displayName: 'Due Date', description: 'Date. Omit to use the payment terms.' }),
+ ref: atomicProps.textProp({ displayName: 'Reference', description: 'Customer reference or vendor bill number.' }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const rawLines = odooInput.parseArray({ value: p.lines, label: 'Lines' });
+ if (rawLines.length === 0) throw new Error('Add at least one line.');
+ odooOperations.checkLineCount({ count: rawLines.length, label: 'lines' });
+ const records = rawLines.map((line, index) => toLineRecord({ line, index }));
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const productIds = await resolveLineProducts({ client, lines: records });
+ const lines = records.map((line, index) => toInvoiceLine({ line, index, productId: productIds[index] }));
+ const values = odooInput.definedOnly({
+ move_type: odooInput.optionalText(p.move_type) ?? 'out_invoice',
+ partner_id: odooInput.toId({ value: p.partner_id, label: 'Partner ID' }),
+ invoice_date: odooDates.inputToOdooDate({ value: p.invoice_date, label: 'Invoice Date' }),
+ invoice_date_due: odooDates.inputToOdooDate({ value: p.invoice_date_due, label: 'Due Date' }),
+ ref: odooInput.optionalText(p.ref),
+ invoice_line_ids: lines,
+ });
+ const id = await client.call<number>({ model: odooApps.invoice.model, method: 'create', args: [values] });
+ return odooRecords.readCreated({ client, model: odooApps.invoice.model, id, wanted: odooApps.invoice.fields, manyToOne: odooApps.invoice.manyToOne });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/create-lead.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/create-lead.ts
new file mode 100644
index 00000000000..c464ec5b539
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/create-lead.ts
@@ -0,0 +1,76 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooOperations } from '../../common/operations';
+import { odooDates, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooCreateLead = createAction({
+ auth: odooAuth,
+ name: 'odoo_create_lead',
+ classification: 'WRITE',
+ displayName: 'Create Lead',
+ description: 'Create a lead or opportunity in Odoo CRM.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates one Odoo CRM record (crm.lead) as a lead or an opportunity (default), with optional customer ID, contact details, expected revenue, probability, stage, salesperson, team, tags and closing date. Needs the CRM app; the "lead" type only shows in Odoo when Leads are enabled in CRM settings. Not idempotent: each call creates a new record. If read_back_error is set, the record was created but could not be read back: do not create it again; read it with odoo_get_records using the returned id.',
+ idempotent: false,
+ },
+ outputSchema: atomicSchemas.createdLead,
+ props: {
+ name: Property.ShortText({ displayName: 'Title', description: 'For example "Website: 20 office chairs".', required: true }),
+ type: Property.StaticDropdown({
+ displayName: 'Type',
+ description: 'opportunity (default) or lead.',
+ required: false,
+ options: { options: [{ label: 'Opportunity', value: 'opportunity' }, { label: 'Lead', value: 'lead' }] },
+ }),
+ partner_id: atomicProps.optionalIdProp({ displayName: 'Customer ID', description: 'res.partner ID from odoo_find_partners.' }),
+ contact_name: atomicProps.textProp({ displayName: 'Contact Name', description: 'Person to talk to.' }),
+ partner_name: atomicProps.textProp({ displayName: 'Company Name', description: 'Company name when there is no customer ID yet.' }),
+ email_from: atomicProps.textProp({ displayName: 'Email', description: 'Contact email.' }),
+ phone: atomicProps.textProp({ displayName: 'Phone', description: 'Contact phone.' }),
+ expected_revenue: Property.Number({ displayName: 'Expected Revenue', description: 'In the company currency.', required: false }),
+ probability: Property.Number({ displayName: 'Probability', description: '0 to 100. Omit to let Odoo compute it.', required: false }),
+ stage_id: atomicProps.optionalIdProp({ displayName: 'Stage ID', description: 'crm.stage ID from odoo_list_crm_stages. Omit for the first stage.' }),
+ user_id: atomicProps.optionalIdProp({ displayName: 'Salesperson User ID', description: 'res.users ID from odoo_list_users. Omit for the connected user.' }),
+ team_id: atomicProps.optionalIdProp({ displayName: 'Sales Team ID', description: 'crm.team ID.' }),
+ tag_ids: Property.Array({ displayName: 'Tag IDs', description: 'crm.tag IDs, for example [1, 3]. Resolve names with odoo_name_search on crm.tag.', required: false }),
+ priority: Property.StaticDropdown({
+ displayName: 'Priority',
+ description: '"0" normal to "3" very high.',
+ required: false,
+ options: { options: [{ label: 'Normal', value: '0' }, { label: 'Medium', value: '1' }, { label: 'High', value: '2' }, { label: 'Very high', value: '3' }] },
+ }),
+ date_deadline: atomicProps.textProp({ displayName: 'Expected Closing', description: 'Date, for example 2026-10-31.' }),
+ description: Property.LongText({ displayName: 'Notes', description: 'Internal notes.', required: false }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const probability = odooInput.toOptionalNumber({ value: p.probability, label: 'Probability' });
+ if (probability !== undefined && (probability < 0 || probability > 100)) throw new Error('Probability must be between 0 and 100.');
+ const tagIds = odooInput.toIdList({ value: p.tag_ids, label: 'Tag IDs', allowEmpty: true });
+ const values = odooInput.definedOnly({
+ name: p.name,
+ type: p.type === 'lead' ? 'lead' : 'opportunity',
+ partner_id: odooInput.optionalId({ value: p.partner_id, label: 'Customer ID' }),
+ contact_name: odooInput.optionalText(p.contact_name),
+ partner_name: odooInput.optionalText(p.partner_name),
+ email_from: odooInput.optionalText(p.email_from),
+ phone: odooInput.optionalText(p.phone),
+ expected_revenue: odooInput.toOptionalNumber({ value: p.expected_revenue, label: 'Expected Revenue' }),
+ probability,
+ stage_id: odooInput.optionalId({ value: p.stage_id, label: 'Stage ID' }),
+ user_id: odooInput.optionalId({ value: p.user_id, label: 'Salesperson User ID' }),
+ team_id: odooInput.optionalId({ value: p.team_id, label: 'Sales Team ID' }),
+ tag_ids: tagIds.length > 0 ? [[6, 0, tagIds]] : undefined,
+ priority: odooInput.optionalText(p.priority),
+ date_deadline: odooDates.inputToOdooDate({ value: p.date_deadline, label: 'Expected Closing' }),
+ description: odooInput.optionalText(p.description),
+ });
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ return odooOperations.createLead({ client, values });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/create-partner.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/create-partner.ts
new file mode 100644
index 00000000000..2b9f957bc6a
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/create-partner.ts
@@ -0,0 +1,72 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+async function countryId({ client, code }: { client: OdooClient; code: string | undefined }): Promise<number | undefined> {
+ if (!code) return undefined;
+ const ids = await client.call<number[]>({ model: 'res.country', method: 'search', args: [[['code', '=', code.trim().toUpperCase()]]], kwargs: { limit: 1 } });
+ if (ids.length === 0) throw new Error(`Unknown country code "${code}". Use a two-letter ISO code such as US.`);
+ return ids[0];
+}
+
+export const odooCreatePartner = createAction({
+ auth: odooAuth,
+ name: 'odoo_create_partner',
+ classification: 'WRITE',
+ displayName: 'Create Contact',
+ description: 'Create a contact person or company in Odoo.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates one Odoo contact (res.partner): a person or a company, optionally linked to a parent company, with email, phone, job, address (country by ISO code) and tax ID. Always creates; call odoo_find_partners first to avoid duplicates. Not idempotent. If read_back_error is set, the record was created but could not be read back: do not create it again; read it with odoo_get_records using the returned id.',
+ idempotent: false,
+ },
+ outputSchema: atomicSchemas.createdPartner,
+ props: {
+ name: Property.ShortText({ displayName: 'Name', description: 'Full name of the person or company.', required: true }),
+ is_company: Property.Checkbox({ displayName: 'Is a Company', description: 'true for a company, false or omitted for a person.', required: false }),
+ parent_id: atomicProps.optionalIdProp({ displayName: 'Parent Company ID', description: 'For a person: the ID of the company they work for.' }),
+ email: atomicProps.textProp({ displayName: 'Email', description: 'For example [email protected]' }),
+ phone: atomicProps.textProp({ displayName: 'Phone', description: 'For example +1 555 0100' }),
+ function: atomicProps.textProp({ displayName: 'Job Position', description: 'For example Buyer' }),
+ website: atomicProps.textProp({ displayName: 'Website', description: 'For example https://acme.example' }),
+ vat: atomicProps.textProp({ displayName: 'Tax ID', description: 'VAT or tax number' }),
+ ref: atomicProps.textProp({ displayName: 'Internal Reference', description: 'Your own code for this contact' }),
+ street: atomicProps.textProp({ displayName: 'Street', description: 'Street and number' }),
+ street2: atomicProps.textProp({ displayName: 'Street 2', description: 'Second address line' }),
+ city: atomicProps.textProp({ displayName: 'City', description: 'City' }),
+ zip: atomicProps.textProp({ displayName: 'ZIP', description: 'Postal code' }),
+ country_code: atomicProps.textProp({ displayName: 'Country Code', description: 'Two-letter ISO code, for example US' }),
+ customer_rank: Property.Number({ displayName: 'Customer Rank', description: 'Needs Invoicing. Set 1 to mark as a customer.', required: false }),
+ supplier_rank: Property.Number({ displayName: 'Supplier Rank', description: 'Needs Invoicing. Set 1 to mark as a vendor.', required: false }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const values = odooInput.definedOnly({
+ name: p.name,
+ is_company: p.is_company === true ? true : undefined,
+ parent_id: odooInput.optionalId({ value: p.parent_id, label: 'Parent Company ID' }),
+ email: odooInput.optionalText(p.email),
+ phone: odooInput.optionalText(p.phone),
+ function: odooInput.optionalText(p.function),
+ website: odooInput.optionalText(p.website),
+ vat: odooInput.optionalText(p.vat),
+ ref: odooInput.optionalText(p.ref),
+ street: odooInput.optionalText(p.street),
+ street2: odooInput.optionalText(p.street2),
+ city: odooInput.optionalText(p.city),
+ zip: odooInput.optionalText(p.zip),
+ country_id: await countryId({ client, code: odooInput.optionalText(p.country_code) }),
+ customer_rank: odooInput.toOptionalNumber({ value: p.customer_rank, label: 'Customer Rank' }),
+ supplier_rank: odooInput.toOptionalNumber({ value: p.supplier_rank, label: 'Supplier Rank' }),
+ });
+ const id = await client.call<number>({ model: odooApps.partner.model, method: 'create', args: [values] });
+ return odooRecords.readCreated({ client, model: odooApps.partner.model, id, wanted: odooApps.partner.fields, manyToOne: odooApps.partner.manyToOne });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/create-product.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/create-product.ts
new file mode 100644
index 00000000000..123b9a4828f
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/create-product.ts
@@ -0,0 +1,97 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient, OdooFieldMap } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { odooInput } from '../../common/values';
+import { atomicSchemas } from './output-schemas';
+
+function typeValues({ kind, fields }: { kind: string; fields: OdooFieldMap }): Record<string, unknown> {
+ if (kind === 'service') {
+ return 'detailed_type' in fields && !('is_storable' in fields) ? { detailed_type: 'service' } : { type: 'service' };
+ }
+ if ('is_storable' in fields) {
+ return kind === 'storable' ? { type: 'consu', is_storable: true } : { type: 'consu' };
+ }
+ const detailed = fields['detailed_type'];
+ if (detailed) {
+ if (kind !== 'storable') return { detailed_type: 'consu' };
+ const options = Array.isArray(detailed.selection) ? detailed.selection.map(([value]) => value) : [];
+ if (options.includes('product')) return { detailed_type: 'product' };
+ throw new Error('Tracked-inventory products need the Inventory app installed in Odoo.');
+ }
+ if (kind === 'storable') throw new Error('Tracked-inventory products need the Inventory app installed in Odoo.');
+ return { type: 'consu' };
+}
+
+async function variantOf({ client, templateId }: { client: OdooClient; templateId: number }): Promise<number> {
+ const [template] = await client.call<{ product_variant_id?: unknown }[]>({
+ model: 'product.template',
+ method: 'read',
+ args: [[templateId]],
+ kwargs: { fields: ['product_variant_id'] },
+ });
+ const variant = template?.product_variant_id;
+ if (Array.isArray(variant) && typeof variant[0] === 'number') return variant[0];
+ throw new Error('it has no product variant');
+}
+
+async function tryVariantOf({ client, templateId }: { client: OdooClient; templateId: number }): Promise<{ found: true; id: number } | { found: false; error: unknown }> {
+ try {
+ return { found: true, id: await variantOf({ client, templateId }) };
+ } catch (error) {
+ return { found: false, error };
+ }
+}
+
+export const odooCreateProduct = createAction({
+ auth: odooAuth,
+ name: 'odoo_create_product',
+ classification: 'WRITE',
+ displayName: 'Create Product',
+ description: 'Create a product in Odoo.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates one Odoo product (product.template) of kind goods (default), service or storable (inventory-tracked, needs the Inventory app), with sales price, cost, internal reference and barcode; maps the kind to the right fields for Odoo 16-17 or 18+. Returns the product variant ID used on order and invoice lines (id is null and product_tmpl_id is set if the variant could not be found). Not idempotent: each call creates a new product. If read_back_error is set, the record was created but could not be read back: do not create it again; read it with odoo_get_records using the returned id.',
+ idempotent: false,
+ },
+ outputSchema: atomicSchemas.createdProduct,
+ props: {
+ name: Property.ShortText({ displayName: 'Name', description: 'Product name.', required: true }),
+ kind: Property.StaticDropdown({
+ displayName: 'Kind',
+ description: 'goods (default), service, or storable (inventory-tracked goods).',
+ required: false,
+ options: { options: [{ label: 'Goods', value: 'goods' }, { label: 'Service', value: 'service' }, { label: 'Storable goods', value: 'storable' }] },
+ }),
+ list_price: Property.Number({ displayName: 'Sales Price', description: 'Unit sales price.', required: false }),
+ standard_price: Property.Number({ displayName: 'Cost', description: 'Unit cost.', required: false }),
+ default_code: Property.ShortText({ displayName: 'Internal Reference', description: 'For example FURN_7800.', required: false }),
+ barcode: Property.ShortText({ displayName: 'Barcode', description: 'Must be unique in Odoo.', required: false }),
+ sale_ok: Property.Checkbox({ displayName: 'Can Be Sold', description: 'Default true in Odoo.', required: false }),
+ purchase_ok: Property.Checkbox({ displayName: 'Can Be Purchased', description: 'Default true in Odoo.', required: false }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const kind = p.kind === 'service' || p.kind === 'storable' ? p.kind : 'goods';
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const fields = await client.fieldsGet('product.template');
+ const values = odooInput.definedOnly({
+ name: p.name,
+ ...typeValues({ kind, fields }),
+ list_price: odooInput.toOptionalNumber({ value: p.list_price, label: 'Sales Price' }),
+ standard_price: odooInput.toOptionalNumber({ value: p.standard_price, label: 'Cost' }),
+ default_code: odooInput.optionalText(p.default_code),
+ barcode: odooInput.optionalText(p.barcode),
+ sale_ok: typeof p.sale_ok === 'boolean' ? p.sale_ok : undefined,
+ purchase_ok: typeof p.purchase_ok === 'boolean' ? p.purchase_ok : undefined,
+ });
+ const templateId = await client.call<number>({ model: 'product.template', method: 'create', args: [values] });
+ const variant = await tryVariantOf({ client, templateId });
+ if (!variant.found) {
+ return odooRecords.unreadCreated({ id: null, known: { product_tmpl_id: templateId }, wanted: odooApps.product.fields, manyToOne: odooApps.product.manyToOne, error: variant.error });
+ }
+ return odooRecords.readCreated({ client, model: odooApps.product.model, id: variant.id, wanted: odooApps.product.fields, manyToOne: odooApps.product.manyToOne });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/create-record.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/create-record.ts
new file mode 100644
index 00000000000..d95cf3ee443
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/create-record.ts
@@ -0,0 +1,45 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooCreateRecord = createAction({
+ auth: odooAuth,
+ name: 'odoo_create_record',
+ classification: 'WRITE',
+ displayName: 'Create Record',
+ description: 'Create a record in any Odoo model from a JSON object of field values.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates one record in any Odoo model from field values (create) and returns its id and display name. Use when no app-specific create action fits; check required fields with odoo_get_model_fields first. Not idempotent: each call creates a new record. If read_back_error is set, the record was created but could not be read back: do not create it again; read it with odoo_get_records using the returned id.',
+ idempotent: false,
+ },
+ outputSchema: atomicSchemas.created,
+ props: {
+ model: atomicProps.modelProp(),
+ values: Property.Json({
+ displayName: 'Values',
+ description:
+ 'JSON object of field values, for example {"name": "Acme", "is_company": true}. Many2one fields take an ID. Many2many/one2many fields take command lists: [[6, 0, [3, 4]]] replaces with IDs 3 and 4, [[4, 7]] adds ID 7, [[0, 0, {"name": "line"}]] creates a line.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const model = odooInput.toModelName(context.propsValue.model);
+ const values = odooInput.parseObject({ value: context.propsValue.values, label: 'Values' });
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const id = await client.call<number>({ model, method: 'create', args: [values] });
+ try {
+ const rows = await client.call<{ display_name?: unknown }[]>({ model, method: 'read', args: [[id]], kwargs: { fields: ['display_name'] } });
+ if (!rows[0]) throw new Error(`${model} record ${id} was not found.`);
+ const displayName = rows[0].display_name;
+ return { id, model, display_name: typeof displayName === 'string' ? displayName : null, read_back_error: null };
+ } catch (error) {
+ return { id, model, display_name: null, read_back_error: odooRecords.readBackReason(error) };
+ }
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/create-sale-order.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/create-sale-order.ts
new file mode 100644
index 00000000000..c8e3ad0276d
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/create-sale-order.ts
@@ -0,0 +1,52 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooOperations } from '../../common/operations';
+import { odooDates, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooCreateSaleOrder = createAction({
+ auth: odooAuth,
+ name: 'odoo_create_sale_order',
+ classification: 'WRITE',
+ displayName: 'Create Quotation',
+ description: 'Create a draft sales order (quotation) in Odoo.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates a draft Odoo quotation (sale.order) for a customer with up to 200 product lines (product ID or internal reference, quantity, optional unit price and description); prices and taxes come from Odoo when omitted. Confirm it with odoo_confirm_sale_order. Needs the Sales app. Not idempotent: each call creates a new quotation. If read_back_error is set, the record was created but could not be read back: do not create it again; read it with odoo_get_records using the returned id.',
+ idempotent: false,
+ },
+ outputSchema: atomicSchemas.createdSaleOrder,
+ props: {
+ partner_id: atomicProps.idProp({ displayName: 'Customer ID', description: 'res.partner ID from odoo_find_partners.' }),
+ lines: Property.Json({
+ displayName: 'Lines',
+ description:
+ 'JSON list of lines, for example [{"product": 12, "quantity": 2}, {"product": "FURN_7800", "quantity": 1, "price_unit": 99.5, "description": "Custom desk"}]. product = product.product ID or internal reference.',
+ required: true,
+ }),
+ client_order_ref: atomicProps.textProp({ displayName: 'Customer Reference', description: 'For example the customer PO number.' }),
+ validity_date: atomicProps.textProp({ displayName: 'Expiration Date', description: 'Date, for example 2026-10-31.' }),
+ user_id: atomicProps.optionalIdProp({ displayName: 'Salesperson User ID', description: 'res.users ID. Omit for the connected user.' }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const lines = odooInput.parseArray({ value: p.lines, label: 'Lines' }).map((line, index) => {
+ if (!odooInput.isRecord(line)) throw new Error(`Line ${index + 1} must be an object with a product.`);
+ return { product: line['product'], quantity: line['quantity'], price_unit: line['price_unit'], description: line['description'] };
+ });
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ return odooOperations.createSaleOrder({
+ client,
+ partnerId: odooInput.toId({ value: p.partner_id, label: 'Customer ID' }),
+ lines,
+ values: odooInput.definedOnly({
+ client_order_ref: odooInput.optionalText(p.client_order_ref),
+ validity_date: odooDates.inputToOdooDate({ value: p.validity_date, label: 'Expiration Date' }),
+ user_id: odooInput.optionalId({ value: p.user_id, label: 'Salesperson User ID' }),
+ }),
+ });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/create-task.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/create-task.ts
new file mode 100644
index 00000000000..70ac91d573a
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/create-task.ts
@@ -0,0 +1,58 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { odooDates, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooCreateTask = createAction({
+ auth: odooAuth,
+ name: 'odoo_create_task',
+ classification: 'WRITE',
+ displayName: 'Create Task',
+ description: 'Create a task in an Odoo project.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Creates one Odoo project task (project.task) in a project, with optional description, assignees, deadline, tags, priority, customer and parent task (sub-task). Needs the Project app. Not idempotent: each call creates a new task. If read_back_error is set, the record was created but could not be read back: do not create it again; read it with odoo_get_records using the returned id.',
+ idempotent: false,
+ },
+ outputSchema: atomicSchemas.createdTask,
+ props: {
+ project_id: atomicProps.idProp({ displayName: 'Project ID', description: 'project.project ID from odoo_list_projects.' }),
+ name: Property.ShortText({ displayName: 'Title', description: 'Task title.', required: true }),
+ description: Property.LongText({ displayName: 'Description', description: 'Task description (plain text or simple HTML).', required: false }),
+ user_ids: Property.Array({ displayName: 'Assignee User IDs', description: 'res.users IDs from odoo_list_users, for example [2].', required: false }),
+ date_deadline: atomicProps.textProp({ displayName: 'Deadline', description: 'Date, for example 2026-10-15.' }),
+ tag_ids: Property.Array({ displayName: 'Tag IDs', description: 'project.tags IDs.', required: false }),
+ priority: Property.StaticDropdown({
+ displayName: 'Priority',
+ description: '"0" normal (default) or "1" high.',
+ required: false,
+ options: { options: [{ label: 'Normal', value: '0' }, { label: 'High', value: '1' }] },
+ }),
+ partner_id: atomicProps.optionalIdProp({ displayName: 'Customer ID', description: 'res.partner ID.' }),
+ parent_id: atomicProps.optionalIdProp({ displayName: 'Parent Task ID', description: 'Create as a sub-task of this task.' }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const userIds = odooInput.toIdList({ value: p.user_ids, label: 'Assignee User IDs', allowEmpty: true });
+ const tagIds = odooInput.toIdList({ value: p.tag_ids, label: 'Tag IDs', allowEmpty: true });
+ const values = odooInput.definedOnly({
+ project_id: odooInput.toId({ value: p.project_id, label: 'Project ID' }),
+ name: p.name,
+ description: odooInput.optionalText(p.description),
+ user_ids: userIds.length > 0 ? [[6, 0, userIds]] : undefined,
+ date_deadline: odooDates.inputToOdooDate({ value: p.date_deadline, label: 'Deadline' }),
+ tag_ids: tagIds.length > 0 ? [[6, 0, tagIds]] : undefined,
+ priority: odooInput.optionalText(p.priority),
+ partner_id: odooInput.optionalId({ value: p.partner_id, label: 'Customer ID' }),
+ parent_id: odooInput.optionalId({ value: p.parent_id, label: 'Parent Task ID' }),
+ });
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const id = await client.call<number>({ model: odooApps.task.model, method: 'create', args: [values] });
+ return odooRecords.readCreated({ client, model: odooApps.task.model, id, wanted: odooApps.task.fields, manyToOne: odooApps.task.manyToOne });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/delete-records.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/delete-records.ts
new file mode 100644
index 00000000000..51f92522c1f
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/delete-records.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooOperations } from '../../common/operations';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooDeleteRecords = createAction({
+ auth: odooAuth,
+ name: 'odoo_delete_records',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Delete Records',
+ description: 'Permanently delete records of any Odoo model.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Permanently deletes records of any Odoo model (unlink); this cannot be undone and Odoo refuses when other records depend on them. Prefer archiving with odoo_call_method action_archive when the record should stay recoverable. Not idempotent: a second call fails because the records are gone.',
+ idempotent: false,
+ },
+ outputSchema: atomicSchemas.deleted,
+ props: {
+ model: atomicProps.modelProp(),
+ ids: atomicProps.idsProp({ description: 'IDs of the records to delete, for example [12]. At most 100.' }),
+ },
+ async run(context) {
+ const model = odooInput.toModelName(context.propsValue.model);
+ const ids = odooInput.toIdList({ value: context.propsValue.ids, label: 'Record IDs' });
+ if (ids.length > 100) throw new Error('Record IDs: at most 100 per call.');
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ return odooOperations.deleteRecords({ client, model, ids });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/download-attachment.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/download-attachment.ts
new file mode 100644
index 00000000000..b431e9c4744
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/download-attachment.ts
@@ -0,0 +1,71 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+function maxFileSizeMb(): number {
+ const configured = Number(process.env['AP_MAX_FILE_SIZE_MB']);
+ return Number.isFinite(configured) && configured > 0 ? configured : DEFAULT_MAX_FILE_SIZE_MB;
+}
+
+export const odooDownloadAttachment = createAction({
+ auth: odooAuth,
+ name: 'odoo_download_attachment',
+ classification: 'READ',
+ displayName: 'Download Attachment',
+ description: 'Download an Odoo attachment as a file.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Downloads one Odoo attachment (ir.attachment) by ID and returns it as a file reference usable by later steps; link-type attachments return their URL and no file. Files larger than the instance file limit (AP_MAX_FILE_SIZE_MB, default 25 MB) are refused before download. Get IDs from odoo_list_record_attachments. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.download,
+ props: {
+ attachment_id: atomicProps.idProp({ displayName: 'Attachment ID', description: 'From odoo_list_record_attachments.' }),
+ },
+ async run(context) {
+ const id = odooInput.toId({ value: context.propsValue.attachment_id, label: 'Attachment ID' });
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const rows = await client.call<Record<string, unknown>[]>({
+ model: 'ir.attachment',
+ method: 'read',
+ args: [[id]],
+ kwargs: { fields: ['name', 'mimetype', 'file_size', 'type', 'url'] },
+ });
+ const row = rows[0];
+ if (!row) throw new Error(`Attachment ${id} was not found.`);
+ const name = typeof row['name'] === 'string' && row['name'] ? row['name'] : `attachment-${id}`;
+ const base = {
+ id,
+ name,
+ mimetype: typeof row['mimetype'] === 'string' ? row['mimetype'] : null,
+ file_size: typeof row['file_size'] === 'number' ? row['file_size'] : null,
+ type: typeof row['type'] === 'string' ? row['type'] : null,
+ url: typeof row['url'] === 'string' ? row['url'] : null,
+ };
+ const maxMb = maxFileSizeMb();
+ if (base.file_size !== null && base.file_size > maxMb * BYTES_PER_MB) {
+ throw new Error(
+ `Attachment ${id} (${name}) is ${(base.file_size / BYTES_PER_MB).toFixed(1)} MB, larger than the ${maxMb} MB file limit of this Activepieces instance. It was not downloaded.`,
+ );
+ }
+ const [content] = await client.call<Record<string, unknown>[]>({
+ model: 'ir.attachment',
+ method: 'read',
+ args: [[id]],
+ kwargs: { fields: ['datas'] },
+ });
+ const datas = content?.['datas'];
+ if (typeof datas !== 'string' || datas.length === 0) {
+ return { ...base, file: null };
+ }
+ const file = await context.files.write({ fileName: name, data: Buffer.from(datas, 'base64') });
+ return { ...base, file };
+ },
+});
+
+const DEFAULT_MAX_FILE_SIZE_MB = 25;
+const BYTES_PER_MB = 1024 * 1024;
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/find-invoices.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/find-invoices.ts
new file mode 100644
index 00000000000..c51a401c215
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/find-invoices.ts
@@ -0,0 +1,68 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooOperations } from '../../common/operations';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooFindInvoices = createAction({
+ auth: odooAuth,
+ name: 'odoo_find_invoices',
+ classification: 'SEARCH',
+ displayName: 'Find Invoices',
+ description: 'Search Odoo invoices, bills and credit notes.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Searches Odoo invoices, vendor bills and credit notes (account.move) by type, status, payment status, partner (including its contacts), number/reference text and invoice or due date ranges, newest first with offset paging. Use for unpaid or overdue invoice questions. Needs Invoicing. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.invoices,
+ props: {
+ move_types: Property.Array({ displayName: 'Types', description: 'Any of out_invoice, in_invoice, out_refund, in_refund. Omit for all four.', required: false }),
+ state: Property.StaticDropdown({
+ displayName: 'Status',
+ description: 'draft, posted or cancel. Omit for all.',
+ required: false,
+ options: { options: [{ label: 'Draft', value: 'draft' }, { label: 'Posted', value: 'posted' }, { label: 'Cancelled', value: 'cancel' }] },
+ }),
+ payment_states: Property.Array({
+ displayName: 'Payment Statuses',
+ description: 'Any of not_paid, partial, in_payment, paid, reversed (blocked on 18+). For unpaid use ["not_paid", "partial"].',
+ required: false,
+ }),
+ partner_id: atomicProps.optionalIdProp({ displayName: 'Partner ID', description: 'res.partner ID; includes its contacts.' }),
+ number: atomicProps.textProp({ displayName: 'Number or Reference Contains', description: 'For example INV/2026/0007.' }),
+ invoice_date_from: atomicProps.textProp({ displayName: 'Invoice Date From', description: 'Date, for example 2026-09-01.' }),
+ invoice_date_to: atomicProps.textProp({ displayName: 'Invoice Date To', description: 'Date.' }),
+ due_date_from: atomicProps.textProp({ displayName: 'Due Date From', description: 'Date.' }),
+ due_date_to: atomicProps.textProp({ displayName: 'Due Date To', description: 'Date. For overdue invoices use yesterday.' }),
+ limit: atomicProps.limitProp({ fallback: 50, max: 500 }),
+ offset: atomicProps.offsetProp(),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const allowedTypes = ['out_invoice', 'in_invoice', 'out_refund', 'in_refund'];
+ const moveTypes = odooInput.toStringList(p.move_types);
+ const bad = moveTypes.filter((t) => !allowedTypes.includes(t));
+ if (bad.length > 0) throw new Error(`Unknown invoice type(s): ${bad.join(', ')}. Use ${allowedTypes.join(', ')}.`);
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ return odooOperations.findInvoices({
+ client,
+ filters: {
+ move_types: moveTypes,
+ state: odooInput.optionalText(p.state),
+ payment_states: odooInput.toStringList(p.payment_states),
+ partner_id: odooInput.optionalId({ value: p.partner_id, label: 'Partner ID' }),
+ number: p.number,
+ invoice_date_from: p.invoice_date_from,
+ invoice_date_to: p.invoice_date_to,
+ due_date_from: p.due_date_from,
+ due_date_to: p.due_date_to,
+ },
+ limit: odooInput.clampLimit({ value: p.limit, fallback: 50, max: 500 }),
+ offset: odooInput.toOffset(p.offset),
+ });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/find-leads.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/find-leads.ts
new file mode 100644
index 00000000000..3b35a72110c
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/find-leads.ts
@@ -0,0 +1,73 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { Condition, Domain, odooDates, odooDomain, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooFindLeads = createAction({
+ auth: odooAuth,
+ name: 'odoo_find_leads',
+ classification: 'SEARCH',
+ displayName: 'Find Leads',
+ description: 'Search Odoo CRM leads and opportunities.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Searches Odoo CRM leads and opportunities (crm.lead) by free text (title, contact, company, email), type, stage, salesperson, team, customer and creation date, newest first with offset paging. Lost (archived) records are excluded unless include_lost is true. Needs the CRM app. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.leads,
+ props: {
+ query: atomicProps.textProp({ displayName: 'Search Text', description: 'Matches title, contact name, company name or email.' }),
+ type: Property.StaticDropdown({
+ displayName: 'Type',
+ description: 'Omit for both.',
+ required: false,
+ options: { options: [{ label: 'Lead', value: 'lead' }, { label: 'Opportunity', value: 'opportunity' }] },
+ }),
+ stage_id: atomicProps.optionalIdProp({ displayName: 'Stage ID', description: 'crm.stage ID.' }),
+ user_id: atomicProps.optionalIdProp({ displayName: 'Salesperson User ID', description: 'res.users ID.' }),
+ team_id: atomicProps.optionalIdProp({ displayName: 'Sales Team ID', description: 'crm.team ID.' }),
+ partner_id: atomicProps.optionalIdProp({ displayName: 'Customer ID', description: 'res.partner ID.' }),
+ created_after: atomicProps.textProp({ displayName: 'Created After', description: 'ISO date or datetime, for example 2026-09-01 or 2026-09-01T08:00:00Z (UTC when no zone).' }),
+ include_lost: Property.Checkbox({ displayName: 'Include Lost', description: 'Also return lost (archived) leads.', required: false }),
+ limit: atomicProps.limitProp({ fallback: 50, max: 500 }),
+ offset: atomicProps.offsetProp(),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const conditions: Condition[] = [];
+ if (p.type === 'lead' || p.type === 'opportunity') conditions.push(['type', '=', p.type]);
+ const ids: [string, unknown, string][] = [
+ ['stage_id', p.stage_id, 'Stage ID'],
+ ['user_id', p.user_id, 'Salesperson User ID'],
+ ['team_id', p.team_id, 'Sales Team ID'],
+ ['partner_id', p.partner_id, 'Customer ID'],
+ ];
+ for (const [field, value, label] of ids) {
+ const id = odooInput.optionalId({ value, label });
+ if (id) conditions.push([field, '=', id]);
+ }
+ const after = odooDates.inputToOdooDatetime({ value: p.created_after, label: 'Created After' });
+ if (after) conditions.push(['create_date', '>=', after]);
+ if (p.include_lost) conditions.push(['active', 'in', [true, false]]);
+ const query = odooInput.optionalText(p.query);
+ const search: Domain = query
+ ? odooDomain.orConditions(['name', 'contact_name', 'partner_name', 'email_from'].map((f): Condition => [f, 'ilike', query]))
+ : [];
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ return odooRecords.findApp({
+ client,
+ model: odooApps.lead.model,
+ wanted: odooApps.lead.fields,
+ manyToOne: odooApps.lead.manyToOne,
+ domain: odooDomain.andDomains([conditions, search]),
+ limit: odooInput.clampLimit({ value: p.limit, fallback: 50, max: 500 }),
+ offset: odooInput.toOffset(p.offset),
+ order: 'create_date desc, id desc',
+ });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/find-partners.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/find-partners.ts
new file mode 100644
index 00000000000..3bf1f57d44f
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/find-partners.ts
@@ -0,0 +1,60 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { Condition, Domain, odooDomain, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooFindPartners = createAction({
+ auth: odooAuth,
+ name: 'odoo_find_partners',
+ classification: 'SEARCH',
+ displayName: 'Find Contacts',
+ description: 'Search Odoo contacts and companies.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Searches Odoo contacts and companies (res.partner) by free text (name, email, phone, reference), exact email, person-or-company, parent company and country code, with offset paging. Use to get a partner ID before creating leads, orders or invoices. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.partners,
+ props: {
+ query: atomicProps.textProp({ displayName: 'Search Text', description: 'Matches name, email, phone or internal reference (contains, any case).' }),
+ email: atomicProps.textProp({ displayName: 'Email (exact)', description: 'Exact email address, any case.' }),
+ is_company: Property.Checkbox({ displayName: 'Companies Only', description: 'true = only companies, false = only people. Omit for both.', required: false }),
+ parent_id: atomicProps.optionalIdProp({ displayName: 'Parent Company ID', description: 'Only contacts that belong to this company.' }),
+ country_code: atomicProps.textProp({ displayName: 'Country Code', description: 'Two-letter ISO code, for example US or BE.' }),
+ include_archived: Property.Checkbox({ displayName: 'Include Archived', description: 'Also return archived contacts.', required: false }),
+ limit: atomicProps.limitProp({ fallback: 50, max: 500 }),
+ offset: atomicProps.offsetProp(),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const map = await client.fieldsGet(odooApps.partner.model);
+ const query = odooInput.optionalText(p.query);
+ const textFields = ['name', 'email', 'phone', 'mobile', 'ref'].filter((name) => name in map);
+ const search: Domain = query ? odooDomain.orConditions(textFields.map((name): Condition => [name, 'ilike', query])) : [];
+ const filters: Condition[] = [];
+ const email = odooInput.optionalText(p.email);
+ if (email) filters.push(['email', '=ilike', email.trim()]);
+ if (p.is_company !== undefined && p.is_company !== null) filters.push(['is_company', '=', p.is_company]);
+ const parentId = odooInput.optionalId({ value: p.parent_id, label: 'Parent Company ID' });
+ if (parentId) filters.push(['parent_id', '=', parentId]);
+ const country = odooInput.optionalText(p.country_code);
+ if (country) filters.push(['country_id.code', '=', country.trim().toUpperCase()]);
+ if (p.include_archived) filters.push(['active', 'in', [true, false]]);
+ return odooRecords.findApp({
+ client,
+ model: odooApps.partner.model,
+ wanted: odooApps.partner.fields,
+ manyToOne: odooApps.partner.manyToOne,
+ domain: odooDomain.andDomains([filters, search]),
+ limit: odooInput.clampLimit({ value: p.limit, fallback: 50, max: 500 }),
+ offset: odooInput.toOffset(p.offset),
+ order: 'name asc, id asc',
+ });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/find-products.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/find-products.ts
new file mode 100644
index 00000000000..c299951b518
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/find-products.ts
@@ -0,0 +1,46 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { Condition, Domain, odooDomain, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooFindProducts = createAction({
+ auth: odooAuth,
+ name: 'odoo_find_products',
+ classification: 'SEARCH',
+ displayName: 'Find Products',
+ description: 'Search Odoo products.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Searches Odoo product variants (product.product) by name, internal reference or barcode, optionally only sellable ones, with offset paging. Returns the variant IDs that sales order and invoice lines need. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.products,
+ props: {
+ query: atomicProps.textProp({ displayName: 'Search Text', description: 'Matches name, internal reference or barcode (contains).' }),
+ sale_ok: Property.Checkbox({ displayName: 'Sellable Only', description: 'Only products that can be sold.', required: false }),
+ limit: atomicProps.limitProp({ fallback: 50, max: 500 }),
+ offset: atomicProps.offsetProp(),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const query = odooInput.optionalText(p.query);
+ const search: Domain = query ? odooDomain.orConditions(['name', 'default_code', 'barcode'].map((f): Condition => [f, 'ilike', query])) : [];
+ const filters: Condition[] = p.sale_ok ? [['sale_ok', '=', true]] : [];
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ return odooRecords.findApp({
+ client,
+ model: odooApps.product.model,
+ wanted: odooApps.product.fields,
+ manyToOne: odooApps.product.manyToOne,
+ domain: odooDomain.andDomains([filters, search]),
+ limit: odooInput.clampLimit({ value: p.limit, fallback: 50, max: 500 }),
+ offset: odooInput.toOffset(p.offset),
+ order: 'default_code asc, name asc, id asc',
+ });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/find-sale-orders.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/find-sale-orders.ts
new file mode 100644
index 00000000000..53e4c9c3378
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/find-sale-orders.ts
@@ -0,0 +1,80 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { Condition, Domain, odooDates, odooDomain, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+function upperBound({ value, label }: { value: unknown; label: string }): Condition | null {
+ const to = odooDates.inputToOdooDatetime({ value, label });
+ if (!to) return null;
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(String(value).trim())) return ['date_order', '<=', to];
+ const start = odooDates.parseOdooDatetime(to);
+ return start === null ? ['date_order', '<=', to] : ['date_order', '<', odooDates.toOdooDatetime(start + DAY_MS)];
+}
+
+export const odooFindSaleOrders = createAction({
+ auth: odooAuth,
+ name: 'odoo_find_sale_orders',
+ classification: 'SEARCH',
+ displayName: 'Find Sales Orders',
+ description: 'Search Odoo quotations and sales orders.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Searches Odoo quotations and sales orders (sale.order) by status, customer (including its contacts), order reference or customer reference, and order date range, newest first with offset paging. Needs the Sales app. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.saleOrders,
+ props: {
+ states: Property.StaticMultiSelectDropdown({
+ displayName: 'Status',
+ description: 'draft = quotation, sent = quotation sent, sale = sales order, cancel = cancelled (done = locked, Odoo 16 only). Omit for all.',
+ required: false,
+ options: {
+ options: [
+ { label: 'Quotation', value: 'draft' },
+ { label: 'Quotation sent', value: 'sent' },
+ { label: 'Sales order', value: 'sale' },
+ { label: 'Locked (Odoo 16)', value: 'done' },
+ { label: 'Cancelled', value: 'cancel' },
+ ],
+ },
+ }),
+ partner_id: atomicProps.optionalIdProp({ displayName: 'Customer ID', description: 'res.partner ID; includes orders of its contacts.' }),
+ reference: atomicProps.textProp({ displayName: 'Reference Contains', description: 'Matches the order number (S00012) or the customer reference.' }),
+ date_from: atomicProps.textProp({ displayName: 'Order Date From', description: 'ISO date or datetime (UTC when no zone).' }),
+ date_to: atomicProps.textProp({ displayName: 'Order Date To', description: 'ISO date or datetime (UTC when no zone). A date alone includes that whole day.' }),
+ limit: atomicProps.limitProp({ fallback: 50, max: 500 }),
+ offset: atomicProps.offsetProp(),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const conditions: Condition[] = [];
+ const states = odooInput.toStringList(p.states);
+ if (states.length > 0) conditions.push(['state', 'in', states]);
+ const partnerId = odooInput.optionalId({ value: p.partner_id, label: 'Customer ID' });
+ if (partnerId) conditions.push(['partner_id', 'child_of', partnerId]);
+ const from = odooDates.inputToOdooDatetime({ value: p.date_from, label: 'Order Date From' });
+ if (from) conditions.push(['date_order', '>=', from]);
+ const to = upperBound({ value: p.date_to, label: 'Order Date To' });
+ if (to) conditions.push(to);
+ const reference = odooInput.optionalText(p.reference);
+ const search: Domain = reference ? odooDomain.orConditions([['name', 'ilike', reference], ['client_order_ref', 'ilike', reference]]) : [];
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ return odooRecords.findApp({
+ client,
+ model: odooApps.saleOrder.model,
+ wanted: odooApps.saleOrder.fields,
+ manyToOne: odooApps.saleOrder.manyToOne,
+ domain: odooDomain.andDomains([conditions, search]),
+ limit: odooInput.clampLimit({ value: p.limit, fallback: 50, max: 500 }),
+ offset: odooInput.toOffset(p.offset),
+ order: 'date_order desc, id desc',
+ });
+ },
+});
+
+const DAY_MS = 24 * 60 * 60 * 1000;
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/find-tasks.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/find-tasks.ts
new file mode 100644
index 00000000000..19bc4601e00
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/find-tasks.ts
@@ -0,0 +1,57 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { Condition, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooFindTasks = createAction({
+ auth: odooAuth,
+ name: 'odoo_find_tasks',
+ classification: 'SEARCH',
+ displayName: 'Find Tasks',
+ description: 'Search Odoo project tasks.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Searches Odoo project tasks (project.task) by project, assignee, stage, customer and title text, newest first with offset paging. Needs the Project app. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.tasks,
+ props: {
+ project_id: atomicProps.optionalIdProp({ displayName: 'Project ID', description: 'project.project ID.' }),
+ user_id: atomicProps.optionalIdProp({ displayName: 'Assignee User ID', description: 'Tasks assigned to this res.users ID.' }),
+ stage_id: atomicProps.optionalIdProp({ displayName: 'Stage ID', description: 'project.task.type ID.' }),
+ partner_id: atomicProps.optionalIdProp({ displayName: 'Customer ID', description: 'res.partner ID.' }),
+ query: atomicProps.textProp({ displayName: 'Title Contains', description: 'Part of the task title.' }),
+ limit: atomicProps.limitProp({ fallback: 50, max: 500 }),
+ offset: atomicProps.offsetProp(),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const conditions: Condition[] = [];
+ const projectId = odooInput.optionalId({ value: p.project_id, label: 'Project ID' });
+ if (projectId) conditions.push(['project_id', '=', projectId]);
+ const userId = odooInput.optionalId({ value: p.user_id, label: 'Assignee User ID' });
+ if (userId) conditions.push(['user_ids', 'in', [userId]]);
+ const stageId = odooInput.optionalId({ value: p.stage_id, label: 'Stage ID' });
+ if (stageId) conditions.push(['stage_id', '=', stageId]);
+ const partnerId = odooInput.optionalId({ value: p.partner_id, label: 'Customer ID' });
+ if (partnerId) conditions.push(['partner_id', '=', partnerId]);
+ const query = odooInput.optionalText(p.query);
+ if (query) conditions.push(['name', 'ilike', query]);
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ return odooRecords.findApp({
+ client,
+ model: odooApps.task.model,
+ wanted: odooApps.task.fields,
+ manyToOne: odooApps.task.manyToOne,
+ domain: conditions,
+ limit: odooInput.clampLimit({ value: p.limit, fallback: 50, max: 500 }),
+ offset: odooInput.toOffset(p.offset),
+ order: 'create_date desc, id desc',
+ });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/get-connection-info.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/get-connection-info.ts
new file mode 100644
index 00000000000..8592ebca12b
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/get-connection-info.ts
@@ -0,0 +1,101 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient, odooRpc } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { atomicSchemas } from './output-schemas';
+
+async function probe({ client, model }: { client: OdooClient; model: string }): Promise<boolean> {
+ try {
+ await client.call<number>({ model, method: 'search_count', args: [[['id', '=', 0]]] });
+ return true;
+ } catch (error) {
+ if (odooRpc.isMissingModelFault(error)) return false;
+ if (odooRpc.isAccessFault(error)) return false;
+ throw error;
+ }
+}
+
+async function installedApps({ client }: { client: OdooClient }): Promise<string[] | null> {
+ try {
+ const rows = await client.call<{ name: string }[]>({
+ model: 'ir.module.module',
+ method: 'search_read',
+ args: [[['state', '=', 'installed'], ['application', '=', true]]],
+ kwargs: { fields: ['name'], order: 'name asc' },
+ });
+ return rows.map((row) => row.name);
+ } catch (error) {
+ if (odooRpc.isAccessFault(error)) return null;
+ throw error;
+ }
+}
+
+async function isAdministrator({ client, uid }: { client: OdooClient; uid: number }): Promise<boolean | null> {
+ try {
+ const result = await client.call<unknown>({ model: 'res.users', method: 'has_group', args: [[uid], 'base.group_system'] });
+ return result === true;
+ } catch (error) {
+ if (!isModelLevelHasGroupFault(error)) return null;
+ }
+ try {
+ const result = await client.call<unknown>({ model: 'res.users', method: 'has_group', args: ['base.group_system'] });
+ return result === true;
+ } catch {
+ return null;
+ }
+}
+
+function isModelLevelHasGroupFault(error: unknown): boolean {
+ return /takes 2 positional arguments/.test(odooRpc.faultText(error));
+}
+
+export const odooGetConnectionInfo = createAction({
+ auth: odooAuth,
+ name: 'odoo_get_connection_info',
+ classification: 'READ',
+ displayName: 'Get Connection Info',
+ description: 'Get the Odoo version, the connected user and which apps can be used.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Returns the Odoo server version, the connected user (id, name, company, language, time zone) and which apps this user can use (contacts, CRM, sales, invoicing, products, project, inventory). Call it first to learn which app-specific actions will work and how field names differ by version. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.connectionInfo,
+ props: {},
+ async run(context) {
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const version = await client.version();
+ const uid = await client.authenticate();
+ const user = await odooRecords.readApp({
+ client,
+ model: 'res.users',
+ id: uid,
+ wanted: ['name', 'login', 'email', 'company_id', 'lang', 'tz'],
+ manyToOne: ['company_id'],
+ });
+ const probes = await Promise.all(
+ odooApps.appProbes.map(async (app): Promise<[string, boolean]> => [app.key, await probe({ client, model: app.model })]),
+ );
+ const apps = await installedApps({ client });
+ const isAdmin = await isAdministrator({ client, uid });
+ return {
+ server_version: version['server_version'] ?? null,
+ server_serie: version['server_serie'] ?? null,
+ protocol_version: version['protocol_version'] ?? null,
+ database: client.connection.db,
+ uid,
+ user_name: user['name'] ?? null,
+ user_login: user['login'] ?? null,
+ user_email: user['email'] ?? null,
+ company_id: user['company_id'] ?? null,
+ company_id_name: user['company_id_name'] ?? null,
+ lang: user['lang'] ?? null,
+ tz: user['tz'] ?? null,
+ is_admin: isAdmin,
+ ...Object.fromEntries(probes),
+ installed_apps: apps,
+ };
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/get-model-fields.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/get-model-fields.ts
new file mode 100644
index 00000000000..16f4c72462d
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/get-model-fields.ts
@@ -0,0 +1,55 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooGetModelFields = createAction({
+ auth: odooAuth,
+ name: 'odoo_get_model_fields',
+ classification: 'READ',
+ displayName: 'Get Model Fields',
+ description: 'List the fields of an Odoo model with their type, whether they are required, and allowed values.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Describes the fields of one Odoo model on this server (fields_get): name, label, type, required, read-only, related model and allowed selection values. Use before creating or updating records or writing a domain, because field names differ between Odoo versions and installed apps. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.modelFields,
+ props: {
+ model: atomicProps.modelProp(),
+ field_names: Property.Array({
+ displayName: 'Only These Fields',
+ description: 'Optional list of field names to describe, for example ["partner_id", "state"]. Empty = all fields.',
+ required: false,
+ }),
+ required_only: Property.Checkbox({
+ displayName: 'Required Fields Only',
+ description: 'Only return fields that must be set when creating a record.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const model = odooInput.toModelName(context.propsValue.model);
+ const only = odooInput.toStringList(context.propsValue.field_names);
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const map = await client.fieldsGet(model);
+ const fields = Object.entries(map)
+ .filter(([name]) => only.length === 0 || only.includes(name))
+ .filter(([, info]) => !context.propsValue.required_only || info.required === true)
+ .map(([name, info]) => ({
+ name,
+ label: info.string ?? name,
+ type: info.type,
+ required: info.required === true,
+ readonly: info.readonly === true,
+ relation: info.relation ?? null,
+ selection: Array.isArray(info.selection) ? info.selection.map(([value, label]) => ({ value, label })) : [],
+ help: typeof info.help === 'string' ? info.help : null,
+ }))
+ .sort((a, b) => a.name.localeCompare(b.name));
+ return { model, count: fields.length, fields };
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/get-records.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/get-records.ts
new file mode 100644
index 00000000000..8033d162aae
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/get-records.ts
@@ -0,0 +1,37 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooGetRecords = createAction({
+ auth: odooAuth,
+ name: 'odoo_get_records',
+ classification: 'READ',
+ displayName: 'Get Records by ID',
+ description: 'Read one or more records of any Odoo model by ID.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Reads records of any Odoo model by their IDs (read) and returns the chosen fields, many2one values split into field and field_name. Use when the IDs are known; fails if any ID does not exist or is not readable. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.genericRecords,
+ props: {
+ model: atomicProps.modelProp(),
+ ids: atomicProps.idsProp({ description: 'Record IDs, for example [12, 15]. At most 500.' }),
+ fields: atomicProps.fieldsProp(),
+ },
+ async run(context) {
+ const model = odooInput.toModelName(context.propsValue.model);
+ const ids = odooInput.toIdList({ value: context.propsValue.ids, label: 'Record IDs' });
+ if (ids.length > 500) throw new Error('Record IDs: at most 500 per call.');
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const { names, map } = await odooRecords.resolveFields({ client, model, fields: odooInput.toStringList(context.propsValue.fields) });
+ const fields = names.includes('display_name') || !('display_name' in map) ? names : [...names, 'display_name'];
+ const records = await odooRecords.readByIds({ client, model, ids, fields, map });
+ return { model, count: records.length, records };
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/index.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/index.ts
new file mode 100644
index 00000000000..da18bf659f4
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/index.ts
@@ -0,0 +1,71 @@
+import { odooAttachFile } from './attach-file';
+import { odooCallMethod } from './call-method';
+import { odooConfirmSaleOrder } from './confirm-sale-order';
+import { odooCountRecords } from './count-records';
+import { odooCreateInvoice } from './create-invoice';
+import { odooCreateLead } from './create-lead';
+import { odooCreatePartner } from './create-partner';
+import { odooCreateProduct } from './create-product';
+import { odooCreateRecord } from './create-record';
+import { odooCreateSaleOrder } from './create-sale-order';
+import { odooCreateTask } from './create-task';
+import { odooDeleteRecords } from './delete-records';
+import { odooDownloadAttachment } from './download-attachment';
+import { odooFindInvoices } from './find-invoices';
+import { odooFindLeads } from './find-leads';
+import { odooFindPartners } from './find-partners';
+import { odooFindProducts } from './find-products';
+import { odooFindSaleOrders } from './find-sale-orders';
+import { odooFindTasks } from './find-tasks';
+import { odooGetConnectionInfo } from './get-connection-info';
+import { odooGetModelFields } from './get-model-fields';
+import { odooGetRecords } from './get-records';
+import { odooListCrmStages } from './list-crm-stages';
+import { odooListModels } from './list-models';
+import { odooListProjects } from './list-projects';
+import { odooListRecordAttachments } from './list-record-attachments';
+import { odooListUsers } from './list-users';
+import { odooMarkLeadLost } from './mark-lead-lost';
+import { odooMarkLeadWon } from './mark-lead-won';
+import { odooNameSearch } from './name-search';
+import { odooPostInvoice } from './post-invoice';
+import { odooPostMessage } from './post-message';
+import { odooSearchRecords } from './search-records';
+import { odooUpdateRecords } from './update-records';
+
+export const odooAtomics = [
+ odooAttachFile,
+ odooCallMethod,
+ odooConfirmSaleOrder,
+ odooCountRecords,
+ odooCreateInvoice,
+ odooCreateLead,
+ odooCreatePartner,
+ odooCreateProduct,
+ odooCreateRecord,
+ odooCreateSaleOrder,
+ odooCreateTask,
+ odooDeleteRecords,
+ odooDownloadAttachment,
+ odooFindInvoices,
+ odooFindLeads,
+ odooFindPartners,
+ odooFindProducts,
+ odooFindSaleOrders,
+ odooFindTasks,
+ odooGetConnectionInfo,
+ odooGetModelFields,
+ odooGetRecords,
+ odooListCrmStages,
+ odooListModels,
+ odooListProjects,
+ odooListRecordAttachments,
+ odooListUsers,
+ odooMarkLeadLost,
+ odooMarkLeadWon,
+ odooNameSearch,
+ odooPostInvoice,
+ odooPostMessage,
+ odooSearchRecords,
+ odooUpdateRecords,
+];
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/list-crm-stages.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/list-crm-stages.ts
new file mode 100644
index 00000000000..d32e1fe2647
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/list-crm-stages.ts
@@ -0,0 +1,57 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { Domain, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooListCrmStages = createAction({
+ auth: odooAuth,
+ name: 'odoo_list_crm_stages',
+ classification: 'SEARCH',
+ displayName: 'List CRM Stages',
+ description: 'List the pipeline stages of Odoo CRM.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists Odoo CRM pipeline stages (crm.stage) in pipeline order, with whether each is the won stage and which sales teams use it; optionally only the stages available to one team. Use to get a stage ID for creating or moving leads. Needs the CRM app. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.stages,
+ props: {
+ team_id: atomicProps.optionalIdProp({ displayName: 'Sales Team ID', description: 'Only stages used by this team, plus shared ones.' }),
+ limit: atomicProps.limitProp({ fallback: 100, max: 500 }),
+ offset: atomicProps.offsetProp(),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const map = await client.fieldsGet(odooApps.stage.model);
+ const teamField = 'team_ids' in map ? 'team_ids' : 'team_id';
+ const teamId = odooInput.optionalId({ value: p.team_id, label: 'Sales Team ID' });
+ const domain: Domain = teamId ? ['|', [teamField, '=', false], [teamField, 'in', [teamId]]] : [];
+ const page = await odooRecords.findApp({
+ client,
+ model: odooApps.stage.model,
+ wanted: odooApps.stage.fields,
+ domain,
+ limit: odooInput.clampLimit({ value: p.limit, fallback: 100, max: 500 }),
+ offset: odooInput.toOffset(p.offset),
+ order: 'sequence asc, id asc',
+ });
+ const records = page.records.map((stage) => {
+ const teamIds = Array.isArray(stage['team_ids']) ? stage['team_ids'] : typeof stage['team_id'] === 'number' ? [stage['team_id']] : [];
+ return {
+ id: stage['id'],
+ name: stage['name'],
+ sequence: stage['sequence'],
+ is_won: stage['is_won'],
+ fold: stage['fold'],
+ team_ids: teamIds,
+ };
+ });
+ return { ...page, records };
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/list-models.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/list-models.ts
new file mode 100644
index 00000000000..c6e1db47957
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/list-models.ts
@@ -0,0 +1,56 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient, odooRpc } from '../../common/client';
+import { Domain, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooListModels = createAction({
+ auth: odooAuth,
+ name: 'odoo_list_models',
+ classification: 'SEARCH',
+ displayName: 'List Models',
+ description: 'Find the technical name of an Odoo model, for example "invoice" → account.move.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Searches the Odoo model registry (ir.model) by technical name or description, for example "invoice" finds account.move, to learn which model to pass to the generic record actions. Returns one page sorted by technical name; when has_more is true, call again with offset = next_offset to get the rest. Needs an Odoo user with Administration / Access Rights; other users get an error and should call odoo_get_model_fields with a known model name instead. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.listModels,
+ props: {
+ query: atomicProps.textProp({
+ displayName: 'Search',
+ description: 'Part of the model name or description, for example "lead", "invoice" or "sale". Empty = all models.',
+ }),
+ limit: atomicProps.limitProp({ fallback: 100, max: 500 }),
+ offset: atomicProps.offsetProp(),
+ },
+ async run(context) {
+ const query = odooInput.optionalText(context.propsValue.query);
+ const domain: Domain = query
+ ? ['&', ['transient', '=', false], '|', ['model', 'ilike', query], ['name', 'ilike', query]]
+ : [['transient', '=', false]];
+ const limit = odooInput.clampLimit({ value: context.propsValue.limit, fallback: 100, max: 500 });
+ const offset = odooInput.toOffset(context.propsValue.offset);
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ try {
+ const rows = await client.call<{ model: string; name: string }[]>({
+ model: 'ir.model',
+ method: 'search_read',
+ args: [domain],
+ kwargs: { fields: ['model', 'name'], order: 'model asc, id asc', offset, limit: limit + 1 },
+ });
+ const hasMore = rows.length > limit;
+ const models = rows.slice(0, limit).map((row) => ({ model: row.model, name: row.name }));
+ return { count: models.length, offset, limit, has_more: hasMore, next_offset: hasMore ? offset + limit : null, models };
+ } catch (error) {
+ if (odooRpc.isAccessFault(error)) {
+ throw new Error(
+ 'This Odoo user cannot list models (it needs Administration / Access Rights). Call odoo_get_model_fields with a known model name such as res.partner, crm.lead, sale.order or account.move instead.',
+ );
+ }
+ throw error;
+ }
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/list-projects.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/list-projects.ts
new file mode 100644
index 00000000000..d4125c331a2
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/list-projects.ts
@@ -0,0 +1,43 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooListProjects = createAction({
+ auth: odooAuth,
+ name: 'odoo_list_projects',
+ classification: 'SEARCH',
+ displayName: 'List Projects',
+ description: 'List Odoo projects.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists Odoo projects (project.project), optionally filtered by name, with customer, manager, dates and task count. Use to get the project ID for creating or finding tasks. Needs the Project app. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.projects,
+ props: {
+ query: atomicProps.textProp({ displayName: 'Name Contains', description: 'Part of the project name.' }),
+ limit: atomicProps.limitProp({ fallback: 50, max: 500 }),
+ offset: atomicProps.offsetProp(),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const query = odooInput.optionalText(p.query);
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ return odooRecords.findApp({
+ client,
+ model: odooApps.project.model,
+ wanted: odooApps.project.fields,
+ manyToOne: odooApps.project.manyToOne,
+ domain: query ? [['name', 'ilike', query]] : [],
+ limit: odooInput.clampLimit({ value: p.limit, fallback: 50, max: 500 }),
+ offset: odooInput.toOffset(p.offset),
+ order: 'name asc, id asc',
+ });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/list-record-attachments.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/list-record-attachments.ts
new file mode 100644
index 00000000000..ed1d696f809
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/list-record-attachments.ts
@@ -0,0 +1,45 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooListRecordAttachments = createAction({
+ auth: odooAuth,
+ name: 'odoo_list_record_attachments',
+ classification: 'SEARCH',
+ displayName: 'List Record Attachments',
+ description: 'List the files attached to an Odoo record.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists the attachments linked to one Odoo record (name, type, size, id) without downloading them; pass an id to odoo_download_attachment to get the file. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.attachments,
+ props: {
+ model: atomicProps.modelProp(),
+ record_id: atomicProps.idProp({ displayName: 'Record ID', description: 'ID of the record whose attachments to list.' }),
+ limit: atomicProps.limitProp({ fallback: 50, max: 200 }),
+ offset: atomicProps.offsetProp(),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ return odooRecords.findApp({
+ client,
+ model: odooApps.attachment.model,
+ wanted: odooApps.attachment.fields,
+ domain: [
+ ['res_model', '=', odooInput.toModelName(p.model)],
+ ['res_id', '=', odooInput.toId({ value: p.record_id, label: 'Record ID' })],
+ ],
+ limit: odooInput.clampLimit({ value: p.limit, fallback: 50, max: 200 }),
+ offset: odooInput.toOffset(p.offset),
+ order: 'id desc',
+ });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/list-users.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/list-users.ts
new file mode 100644
index 00000000000..37c3a90f1d9
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/list-users.ts
@@ -0,0 +1,44 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { Condition, odooDomain, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooListUsers = createAction({
+ auth: odooAuth,
+ name: 'odoo_list_users',
+ classification: 'SEARCH',
+ displayName: 'List Users',
+ description: 'List internal Odoo users (salespeople, assignees).',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Lists internal Odoo users (res.users, portal users excluded), optionally filtered by name, login or email. Use to get the user ID for salesperson, project manager or task assignee fields. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.users,
+ props: {
+ query: atomicProps.textProp({ displayName: 'Search Text', description: 'Matches name, login or email (contains).' }),
+ limit: atomicProps.limitProp({ fallback: 50, max: 500 }),
+ offset: atomicProps.offsetProp(),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const query = odooInput.optionalText(p.query);
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const search = query ? odooDomain.orConditions(['name', 'login', 'email'].map((f): Condition => [f, 'ilike', query])) : [];
+ return odooRecords.findApp({
+ client,
+ model: odooApps.user.model,
+ wanted: odooApps.user.fields,
+ manyToOne: odooApps.user.manyToOne,
+ domain: odooDomain.andDomains([[['share', '=', false]], search]),
+ limit: odooInput.clampLimit({ value: p.limit, fallback: 50, max: 500 }),
+ offset: odooInput.toOffset(p.offset),
+ order: 'name asc, id asc',
+ });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/mark-lead-lost.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/mark-lead-lost.ts
new file mode 100644
index 00000000000..ba66d9b07fb
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/mark-lead-lost.ts
@@ -0,0 +1,39 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooMarkLeadLost = createAction({
+ auth: odooAuth,
+ name: 'odoo_mark_lead_lost',
+ classification: 'WRITE',
+ displayName: 'Mark Lead Lost',
+ description: 'Mark an Odoo CRM lead or opportunity as lost.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Marks one Odoo CRM lead or opportunity as lost (action_set_lost), which archives it, with an optional lost reason. Recover it later with odoo_mark_lead_won or odoo_call_method action_unarchive. Needs the CRM app. Idempotent: a second call leaves it lost.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.lead,
+ props: {
+ lead_id: atomicProps.idProp({ displayName: 'Lead ID', description: 'crm.lead ID from odoo_find_leads.' }),
+ lost_reason_id: atomicProps.optionalIdProp({ displayName: 'Lost Reason ID', description: 'crm.lost.reason ID. Resolve with odoo_name_search on crm.lost.reason.' }),
+ },
+ async run(context) {
+ const id = odooInput.toId({ value: context.propsValue.lead_id, label: 'Lead ID' });
+ const reason = odooInput.optionalId({ value: context.propsValue.lost_reason_id, label: 'Lost Reason ID' });
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ await client.callAllowNone({
+ model: odooApps.lead.model,
+ method: 'action_set_lost',
+ args: [[id]],
+ kwargs: odooInput.definedOnly({ lost_reason_id: reason }),
+ });
+ return odooRecords.readApp({ client, model: odooApps.lead.model, id, wanted: odooApps.lead.fields, manyToOne: odooApps.lead.manyToOne });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/mark-lead-won.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/mark-lead-won.ts
new file mode 100644
index 00000000000..1084e0bcf6c
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/mark-lead-won.ts
@@ -0,0 +1,32 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooMarkLeadWon = createAction({
+ auth: odooAuth,
+ name: 'odoo_mark_lead_won',
+ classification: 'WRITE',
+ displayName: 'Mark Lead Won',
+ description: 'Mark an Odoo CRM opportunity as won.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Marks one Odoo CRM lead or opportunity as won (action_set_won): moves it to the won stage and sets probability to 100, restoring it first if it was lost. Needs the CRM app. Idempotent: a second call leaves it won.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.lead,
+ props: {
+ lead_id: atomicProps.idProp({ displayName: 'Lead ID', description: 'crm.lead ID from odoo_find_leads.' }),
+ },
+ async run(context) {
+ const id = odooInput.toId({ value: context.propsValue.lead_id, label: 'Lead ID' });
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ await client.callAllowNone({ model: odooApps.lead.model, method: 'action_set_won', args: [[id]] });
+ return odooRecords.readApp({ client, model: odooApps.lead.model, id, wanted: odooApps.lead.fields, manyToOne: odooApps.lead.manyToOne });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/name-search.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/name-search.ts
new file mode 100644
index 00000000000..e32b4350c4b
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/name-search.ts
@@ -0,0 +1,46 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooDomain, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooNameSearch = createAction({
+ auth: odooAuth,
+ name: 'odoo_name_search',
+ classification: 'SEARCH',
+ displayName: 'Find ID by Name',
+ description: 'Find record IDs by name, like typing in an Odoo selection field.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Resolves a name to record IDs the way Odoo selection fields do (name_search), for example a customer, product, stage, user, country or tag name to the ID needed in create or update values. Returns id and name pairs, best matches first; has_more is true when more records match than the limit, so narrow the name or raise the limit. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.nameSearch,
+ props: {
+ model: atomicProps.modelProp(),
+ name: Property.ShortText({ displayName: 'Name', description: 'Text to match, for example "Acme". Empty = first records.', required: false }),
+ domain: atomicProps.domainProp(),
+ operator: Property.StaticDropdown({
+ displayName: 'Match',
+ description: 'ilike = contains (default), = = exact name.',
+ required: false,
+ options: { options: [{ label: 'Contains', value: 'ilike' }, { label: 'Exact', value: '=' }, { label: 'Exact, any case', value: '=ilike' }] },
+ }),
+ limit: atomicProps.limitProp({ fallback: 10, max: 100 }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const model = odooInput.toModelName(p.model);
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const limit = odooInput.clampLimit({ value: p.limit, fallback: 10, max: 100 });
+ const rows = await client.call<[number, string][]>({
+ model,
+ method: 'name_search',
+ args: [p.name ?? '', odooDomain.parseDomain({ value: p.domain }), p.operator ?? 'ilike', limit + 1],
+ });
+ const results = rows.slice(0, limit).map(([id, name]) => ({ id, name }));
+ return { model, count: results.length, has_more: rows.length > limit, results };
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/output-schemas.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/output-schemas.ts
new file mode 100644
index 00000000000..ba02257b89b
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/output-schemas.ts
@@ -0,0 +1,160 @@
+import { OutputSchema } from '@activepieces/pieces-framework';
+import { odooSchemaFields } from '../../output-schemas';
+
+const f = odooSchemaFields;
+
+const genericPage: OutputSchema = {
+ fields: [...f.pageFields, { key: 'records', label: 'Records', labelKey: 'display_name' }],
+};
+
+export const atomicSchemas = {
+ connectionInfo: {
+ fields: [
+ { key: 'server_version', label: 'Server Version' },
+ { key: 'server_serie', label: 'Server Series', description: 'For example 18.0 or saas~18.3' },
+ { key: 'protocol_version', label: 'Protocol Version', format: 'number' },
+ { key: 'database', label: 'Database' },
+ { key: 'uid', label: 'User ID', format: 'number' },
+ { key: 'user_name', label: 'User Name' },
+ { key: 'user_login', label: 'User Login' },
+ { key: 'user_email', label: 'User Email', format: 'email' },
+ { key: 'company_id', label: 'Company ID', format: 'number' },
+ { key: 'company_id_name', label: 'Company' },
+ { key: 'lang', label: 'Language' },
+ { key: 'tz', label: 'Time Zone' },
+ { key: 'is_admin', label: 'Is Administrator', format: 'boolean', description: 'true when the user has Settings access; null if Odoo did not say' },
+ { key: 'has_contacts', label: 'Contacts Available', format: 'boolean' },
+ { key: 'has_crm', label: 'CRM Available', format: 'boolean' },
+ { key: 'has_sales', label: 'Sales Available', format: 'boolean' },
+ { key: 'has_invoicing', label: 'Invoicing Available', format: 'boolean' },
+ { key: 'has_products', label: 'Products Available', format: 'boolean' },
+ { key: 'has_project', label: 'Project Available', format: 'boolean' },
+ { key: 'has_inventory', label: 'Inventory Available', format: 'boolean' },
+ { key: 'installed_apps', label: 'Installed Apps', description: 'Installed application module names; null when this user cannot read the module list' },
+ ],
+ },
+ listModels: {
+ fields: [
+ ...f.pageFields.filter((field) => field.key !== 'model'),
+ {
+ key: 'models',
+ label: 'Models',
+ labelKey: 'model',
+ listItems: [
+ { key: 'model', label: 'Technical Name' },
+ { key: 'name', label: 'Description' },
+ ],
+ },
+ ],
+ },
+ modelFields: {
+ fields: [
+ { key: 'model', label: 'Model' },
+ { key: 'count', label: 'Count', format: 'number' },
+ {
+ key: 'fields',
+ label: 'Fields',
+ labelKey: 'name',
+ listItems: [
+ { key: 'name', label: 'Field Name' },
+ { key: 'label', label: 'Label' },
+ { key: 'type', label: 'Type' },
+ { key: 'required', label: 'Required', format: 'boolean' },
+ { key: 'readonly', label: 'Read Only', format: 'boolean' },
+ { key: 'relation', label: 'Related Model' },
+ { key: 'selection', label: 'Allowed Values', labelKey: 'value', listItems: [{ key: 'value', label: 'Value' }, { key: 'label', label: 'Label' }] },
+ { key: 'help', label: 'Help' },
+ ],
+ },
+ ],
+ },
+ genericPage,
+ genericRecords: {
+ fields: [
+ { key: 'model', label: 'Model' },
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'records', label: 'Records', labelKey: 'display_name' },
+ ],
+ },
+ count: {
+ fields: [
+ { key: 'model', label: 'Model' },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+ },
+ nameSearch: {
+ fields: [
+ { key: 'model', label: 'Model' },
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'has_more', label: 'Has More', format: 'boolean', description: 'true when more records match than the limit' },
+ { key: 'results', label: 'Matches', labelKey: 'name', listItems: [{ key: 'id', label: 'ID', format: 'number' }, { key: 'name', label: 'Name' }] },
+ ],
+ },
+ created: {
+ fields: [
+ { key: 'id', label: 'New Record ID', format: 'number' },
+ { key: 'model', label: 'Model' },
+ { key: 'display_name', label: 'Display Name' },
+ f.readBackField,
+ ],
+ },
+ updated: {
+ fields: [
+ { key: 'success', label: 'Success', format: 'boolean' },
+ { key: 'model', label: 'Model' },
+ { key: 'ids', label: 'Updated IDs' },
+ { key: 'updated_count', label: 'Updated Count', format: 'number' },
+ ],
+ },
+ deleted: {
+ fields: [
+ { key: 'success', label: 'Success', format: 'boolean' },
+ { key: 'model', label: 'Model' },
+ { key: 'deleted_ids', label: 'Deleted IDs' },
+ ],
+ },
+ download: {
+ fields: [
+ { key: 'id', label: 'Attachment ID', format: 'number' },
+ { key: 'name', label: 'File Name' },
+ { key: 'mimetype', label: 'MIME Type' },
+ { key: 'file_size', label: 'Size', format: 'filesize' },
+ { key: 'type', label: 'Storage Type' },
+ { key: 'url', label: 'External URL', format: 'url' },
+ { key: 'file', label: 'File', format: 'url' },
+ ],
+ },
+ attachments: f.pageOf({ label: 'Attachments', labelKey: 'name', items: f.attachmentFields }),
+ partners: f.pageOf({ label: 'Contacts', labelKey: 'display_name', items: f.partnerFields }),
+ leads: f.pageOf({ label: 'Leads', labelKey: 'name', items: f.leadFields }),
+ stages: f.pageOf({ label: 'Stages', labelKey: 'name', items: f.stageFields }),
+ saleOrders: f.pageOf({ label: 'Sales Orders', labelKey: 'name', items: f.saleOrderFields }),
+ invoices: f.pageOf({ label: 'Invoices', labelKey: 'name', items: f.invoiceFields }),
+ products: f.pageOf({ label: 'Products', labelKey: 'display_name', items: f.productFields }),
+ projects: f.pageOf({ label: 'Projects', labelKey: 'name', items: f.projectFields }),
+ tasks: f.pageOf({ label: 'Tasks', labelKey: 'name', items: f.taskFields }),
+ users: f.pageOf({ label: 'Users', labelKey: 'name', items: f.userFields }),
+ partner: { fields: f.partnerFields },
+ lead: { fields: f.leadFields },
+ saleOrder: { fields: f.saleOrderFields },
+ invoice: { fields: f.invoiceFields },
+ product: { fields: f.productFields },
+ task: { fields: f.taskFields },
+ attachment: { fields: f.attachmentFields },
+ createdPartner: { fields: [...f.partnerFields, f.readBackField] },
+ createdLead: { fields: [...f.leadFields, f.readBackField] },
+ createdSaleOrder: { fields: [...f.saleOrderFields, f.readBackField] },
+ createdInvoice: { fields: [...f.invoiceFields, f.readBackField] },
+ createdProduct: {
+ fields: [
+ ...f.productFields,
+ {
+ ...f.readBackField,
+ description:
+ 'null when the new product was read back. Otherwise why reading it failed: the product was still created. If its variant could not be found, id is null and product_tmpl_id holds the new template ID.',
+ },
+ ],
+ },
+ createdTask: { fields: [...f.taskFields, f.readBackField] },
+ createdAttachment: { fields: [...f.attachmentFields, f.readBackField] },
+} satisfies Record<string, OutputSchema>;
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/post-invoice.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/post-invoice.ts
new file mode 100644
index 00000000000..bd634c90890
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/post-invoice.ts
@@ -0,0 +1,36 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { odooApps } from '../../common/app-fields';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooPostInvoice = createAction({
+ auth: odooAuth,
+ name: 'odoo_post_invoice',
+ classification: 'WRITE',
+ displayName: 'Post Invoice',
+ description: 'Validate (post) a draft Odoo invoice so it gets its number.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Posts one draft Odoo invoice, bill or credit note (action_post): it gets its final number and becomes due; fails if Odoo asks for an extra confirmation step. Needs Invoicing. Not idempotent: a second call fails because only drafts can be posted.',
+ idempotent: false,
+ },
+ outputSchema: atomicSchemas.invoice,
+ props: {
+ invoice_id: atomicProps.idProp({ displayName: 'Invoice ID', description: 'account.move ID from odoo_create_invoice or odoo_find_invoices.' }),
+ },
+ async run(context) {
+ const id = odooInput.toId({ value: context.propsValue.invoice_id, label: 'Invoice ID' });
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ await client.callAllowNone({ model: odooApps.invoice.model, method: 'action_post', args: [[id]] });
+ const invoice = await odooRecords.readApp({ client, model: odooApps.invoice.model, id, wanted: odooApps.invoice.fields, manyToOne: odooApps.invoice.manyToOne });
+ if (invoice['state'] === 'draft') {
+ throw new Error('Odoo asked for a confirmation step before posting this invoice. Post it from the Odoo screen.');
+ }
+ return invoice;
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/post-message.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/post-message.ts
new file mode 100644
index 00000000000..19e2cc5c633
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/post-message.ts
@@ -0,0 +1,55 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooOperations } from '../../common/operations';
+import { odooInput } from '../../common/values';
+import { postMessageOutputSchema } from '../../output-schemas';
+import { atomicProps } from './common';
+
+export const odooPostMessage = createAction({
+ auth: odooAuth,
+ name: 'odoo_post_message',
+ classification: 'WRITE',
+ displayName: 'Post Message on Record',
+ description: 'Post an internal note or a message in the chatter of an Odoo record.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Posts in the chatter of one Odoo record (message_post): an internal note (default, no email) or a message emailed to the followers and to extra partners. Works on models with a chatter such as res.partner, crm.lead, sale.order, account.move, project.task. Not idempotent: each call posts another message.',
+ idempotent: false,
+ },
+ outputSchema: postMessageOutputSchema,
+ props: {
+ model: atomicProps.modelProp(),
+ record_id: atomicProps.idProp({ displayName: 'Record ID', description: 'ID of the record to post on.' }),
+ body: Property.LongText({ displayName: 'Body', description: 'Plain text of the message. HTML tags are shown as text.', required: true }),
+ kind: Property.StaticDropdown({
+ displayName: 'Kind',
+ description: 'note = internal note (default). message = sent to followers by email.',
+ required: false,
+ options: { options: [{ label: 'Internal note', value: 'note' }, { label: 'Message to followers', value: 'message' }] },
+ }),
+ partner_ids: Property.Array({
+ displayName: 'Also Notify Partner IDs',
+ description: 'Contact IDs (res.partner) to notify in addition to followers, for example [7]. Only used with kind "message".',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const body = odooInput.optionalText(p.body);
+ if (!body) throw new Error('Body cannot be empty.');
+ const kind = p.kind === 'message' ? 'message' : 'note';
+ const partnerIds = odooInput.toIdList({ value: p.partner_ids, label: 'Partner IDs', allowEmpty: true });
+ if (kind === 'note' && partnerIds.length > 0) throw new Error('Partner IDs are only used with kind "message".');
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ return odooOperations.postMessage({
+ client,
+ model: odooInput.toModelName(p.model),
+ recordId: odooInput.toId({ value: p.record_id, label: 'Record ID' }),
+ body,
+ kind,
+ partnerIds,
+ });
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/search-records.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/search-records.ts
new file mode 100644
index 00000000000..d1076e31313
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/search-records.ts
@@ -0,0 +1,46 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { odooDomain, odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooSearchRecords = createAction({
+ auth: odooAuth,
+ name: 'odoo_search_records',
+ classification: 'SEARCH',
+ displayName: 'Search Records',
+ description: 'Search any Odoo model with a domain and return the chosen fields.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Searches records of any Odoo model with an Odoo domain and returns the chosen fields (search_read), with sort order and offset paging (has_more / next_offset). Many2one values come back as field (id) plus field_name. Prefer the app-specific find actions (partners, leads, orders, invoices, products, tasks) when they fit. Read-only and idempotent.',
+ idempotent: true,
+ },
+ outputSchema: atomicSchemas.genericPage,
+ props: {
+ model: atomicProps.modelProp(),
+ domain: atomicProps.domainProp(),
+ fields: atomicProps.fieldsProp(),
+ order: Property.ShortText({
+ displayName: 'Order',
+ description: 'Sort, for example "create_date desc, id desc". Empty = the model default order.',
+ required: false,
+ }),
+ limit: atomicProps.limitProp({ fallback: 50, max: 500 }),
+ offset: atomicProps.offsetProp(),
+ },
+ async run(context) {
+ const p = context.propsValue;
+ const model = odooInput.toModelName(p.model);
+ const domain = odooDomain.parseDomain({ value: p.domain });
+ const limit = odooInput.clampLimit({ value: p.limit, fallback: 50, max: 500 });
+ const offset = odooInput.toOffset(p.offset);
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ const { names, map } = await odooRecords.resolveFields({ client, model, fields: odooInput.toStringList(p.fields) });
+ const fields = names.includes('display_name') || !('display_name' in map) ? names : [...names, 'display_name'];
+ const page = await odooRecords.searchPage({ client, model, domain, fields, map, limit, offset, order: odooInput.optionalText(p.order) });
+ return { model, count: page.records.length, offset, limit, has_more: page.has_more, next_offset: page.next_offset, records: page.records };
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/atomics/update-records.ts b/packages/pieces/community/odoo/src/lib/actions/atomics/update-records.ts
new file mode 100644
index 00000000000..a7b4164a1cf
--- /dev/null
+++ b/packages/pieces/community/odoo/src/lib/actions/atomics/update-records.ts
@@ -0,0 +1,42 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { odooAuth } from '../../auth';
+import { OdooClient } from '../../common/client';
+import { odooRecords } from '../../common/records';
+import { odooInput } from '../../common/values';
+import { atomicProps } from './common';
+import { atomicSchemas } from './output-schemas';
+
+export const odooUpdateRecords = createAction({
+ auth: odooAuth,
+ name: 'odoo_update_records',
+ classification: 'WRITE',
+ displayName: 'Update Records',
+ description: 'Set field values on one or more records of any Odoo model.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Writes the given field values to one or more records of any Odoo model (write). Only the fields in Values change; every other field keeps its value. Send null or false to clear a field. Idempotent for plain values: writing the same values again leaves the records unchanged. x2many commands such as [0, 0, {...}] add lines on every call, so a retry can duplicate them; that is why this action is marked not idempotent.',
+ idempotent: false,
+ },
+ outputSchema: atomicSchemas.updated,
+ props: {
+ model: atomicProps.modelProp(),
+ ids: atomicProps.idsProp({ description: 'IDs of the records to update, for example [12]. At most 500.' }),
+ values: Property.Json({
+ displayName: 'Values',
+ description:
+ 'JSON object with only the fields to change, for example {"phone": "+1 555 0100"}. Same value format as odoo_create_record (IDs for many2one, command lists for many2many).',
+ required: true,
+ }),
+ },
+ async run(context) {
+ const model = odooInput.toModelName(context.propsValue.model);
+ const ids = odooInput.toIdList({ value: context.propsValue.ids, label: 'Record IDs' });
+ if (ids.length > 500) throw new Error('Record IDs: at most 500 per call.');
+ const values = odooInput.parseObject({ value: context.propsValue.values, label: 'Values' });
+ const client = OdooClient.fromAuth({ auth: context.auth.props });
+ await odooRecords.assertKnownFields({ client, model, names: Object.keys(values) });
+ await client.call<boolean>({ model, method: 'write', args: [ids, values] });
+ return { success: true, model, ids, updated_count: ids.length };
+ },
+});
diff --git a/packages/pieces/community/odoo/src/lib/actions/attach-file.ts b/packages/pieces/community/odoo/src/lib/actions/attach-file.ts
index 690c8b8b1ef..c318dc6fd0d 100644
--- a/packages/pieces/community/odoo/src/lib/actions/attach-file.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/attach-file.ts
@@ -12,7 +12,7 @@ export const attachFileAction = createAction({
classification: 'WRITE',
displayName: 'Attach File to Record',
description: 'Attach a file to a record, for example a signed PDF to a sales order.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Uploads a file as an attachment (ir.attachment) linked to one Odoo record, shown in its chatter attachments. Not idempotent: each call adds another attachment. If read_back_error is set, the record was created but could not be read back: do not create it again; open it with Get Record using the returned id.',
diff --git a/packages/pieces/community/odoo/src/lib/actions/create-company.ts b/packages/pieces/community/odoo/src/lib/actions/create-company.ts
index 66f38b9f111..153f08e8b0a 100644
--- a/packages/pieces/community/odoo/src/lib/actions/create-company.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/create-company.ts
@@ -9,7 +9,7 @@ export default createAction({
auth: odooAuth,
displayName: 'Create company',
description: 'Create/Update company on Odoo',
- audience: 'both',
+ audience: 'human',
aiMetadata: { description: 'Upserts a company partner (res.partner with is_company set) in Odoo by name: it searches for a company with the same name, updating it if found or creating one otherwise, setting phone and email. Use to add or refresh a company record. Not idempotent in effect — the first call may create a record and matching is by exact name.', idempotent: false },
props: {
// Properties to ask from the user, in this ask we will take number of
diff --git a/packages/pieces/community/odoo/src/lib/actions/create-contact.ts b/packages/pieces/community/odoo/src/lib/actions/create-contact.ts
index b6676f5f2ad..a24380e82a0 100644
--- a/packages/pieces/community/odoo/src/lib/actions/create-contact.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/create-contact.ts
@@ -9,7 +9,7 @@ export default createAction({
auth: odooAuth,
displayName: 'Create contact',
description: 'Create/Update contact on Odoo',
- audience: 'both',
+ audience: 'human',
aiMetadata: { description: 'Upserts an individual contact (res.partner) in Odoo by name: it searches for a non-company partner with the same name, updating it if found or creating one otherwise. Use to add or refresh a person contact with phone, email, company name, and job title. Not idempotent in effect — the first call may create a record and matching is by exact name.', idempotent: false },
props: {
// Properties to ask from the user, in this ask we will take number of
diff --git a/packages/pieces/community/odoo/src/lib/actions/create-lead.ts b/packages/pieces/community/odoo/src/lib/actions/create-lead.ts
index 193d4b16bd5..9de34748368 100644
--- a/packages/pieces/community/odoo/src/lib/actions/create-lead.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/create-lead.ts
@@ -12,7 +12,7 @@ export const createLeadAction = createAction({
classification: 'WRITE',
displayName: 'Create Lead or Opportunity',
description: 'Create a lead or opportunity in Odoo CRM.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Creates one Odoo CRM record (crm.lead) as a lead or an opportunity, with optional customer, contact details, revenue, stage, salesperson and team. Needs the CRM app. Not idempotent: each call creates a new record. If read_back_error is set, the record was created but could not be read back: do not create it again; open it with Get Record using the returned id.',
diff --git a/packages/pieces/community/odoo/src/lib/actions/create-record.ts b/packages/pieces/community/odoo/src/lib/actions/create-record.ts
index 3010e4d202f..fb645465cb8 100644
--- a/packages/pieces/community/odoo/src/lib/actions/create-record.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/create-record.ts
@@ -10,7 +10,7 @@ export default createAction({
auth: odooAuth,
displayName: 'Custom Create Record',
description: 'Create a new record in the specified model',
- audience: 'both',
+ audience: 'human',
aiMetadata: { description: 'Creates a new record in any Odoo model via the XML-RPC create call, given a model name and a JSON object of field names to values, and returns the new record id. Use this generic writer when no model-specific create action fits. Not idempotent — each call inserts a new record.', idempotent: false },
outputSchema: createRecordOutputSchema,
props: {
diff --git a/packages/pieces/community/odoo/src/lib/actions/create-sales-order.ts b/packages/pieces/community/odoo/src/lib/actions/create-sales-order.ts
index 23b51772ef4..4d6958daa7c 100644
--- a/packages/pieces/community/odoo/src/lib/actions/create-sales-order.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/create-sales-order.ts
@@ -12,7 +12,7 @@ export const createSalesOrderAction = createAction({
classification: 'WRITE',
displayName: 'Create Quotation',
description: 'Create a quotation (draft sales order) with order lines.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Creates a draft Odoo quotation (sale.order) for a customer with one or more product lines; confirm it afterwards with action_confirm. Needs the Sales app. Not idempotent: each call creates a new quotation. If read_back_error is set, the record was created but could not be read back: do not create it again; open it with Get Record using the returned id.',
diff --git a/packages/pieces/community/odoo/src/lib/actions/custom-api-call.ts b/packages/pieces/community/odoo/src/lib/actions/custom-api-call.ts
index 6ebfb863f4c..46294bac24e 100644
--- a/packages/pieces/community/odoo/src/lib/actions/custom-api-call.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/custom-api-call.ts
@@ -11,7 +11,7 @@ export const customOdooApiCall = createAction({
classification: 'WRITE',
displayName: 'Custom API Call',
description: 'Make a custom XML-RPC API call to Odoo',
- audience: 'both',
+ audience: 'human',
aiMetadata: { description: 'Invokes any Odoo model method over XML-RPC (e.g. search, read, search_read, create, write, unlink) with arbitrary positional and keyword arguments. Use as an escape hatch when no dedicated Odoo action covers the operation. Idempotency depends on the method called: reads and searches are safe to repeat, while create, write, and unlink are not.', idempotent: false },
auth: odooAuth,
props: {
diff --git a/packages/pieces/community/odoo/src/lib/actions/delete-record.ts b/packages/pieces/community/odoo/src/lib/actions/delete-record.ts
index b4fc35bbb9b..2f1e770fdde 100644
--- a/packages/pieces/community/odoo/src/lib/actions/delete-record.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/delete-record.ts
@@ -12,7 +12,7 @@ export const deleteRecordAction = createAction({
classification: 'DESTRUCTIVE',
displayName: 'Delete Record',
description: 'Permanently delete a record of any Odoo model. This cannot be undone.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Permanently deletes one Odoo record of any model (unlink). Odoo may refuse when other records depend on it; archiving via Run Record Action with action_archive is the recoverable alternative. Not idempotent: a second call fails because the record is gone.',
diff --git a/packages/pieces/community/odoo/src/lib/actions/find-invoices.ts b/packages/pieces/community/odoo/src/lib/actions/find-invoices.ts
index 8e61091c65e..d31043654cc 100644
--- a/packages/pieces/community/odoo/src/lib/actions/find-invoices.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/find-invoices.ts
@@ -12,7 +12,7 @@ export const findInvoicesAction = createAction({
classification: 'SEARCH',
displayName: 'Find Invoices',
description: 'List invoices, bills and credit notes, filtered by type, status, customer and dates.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Searches Odoo invoices, vendor bills and credit notes (account.move) by type, status, payment status, partner (including its contacts), number and invoice/due date ranges, newest first with offset paging. Needs Invoicing. Read-only and idempotent.',
diff --git a/packages/pieces/community/odoo/src/lib/actions/get-contacts.ts b/packages/pieces/community/odoo/src/lib/actions/get-contacts.ts
index 7da3bf51e4d..ade88d39693 100644
--- a/packages/pieces/community/odoo/src/lib/actions/get-contacts.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/get-contacts.ts
@@ -9,7 +9,7 @@ export default createAction({
auth: odooAuth,
displayName: 'Get contacts',
description: 'Get contacts on Odoo',
- audience: 'both',
+ audience: 'human',
aiMetadata: { description: 'Reads contacts (res.partner records) from Odoo, scoped by a required type flag that selects either individual contacts or companies. Operates in two modes: leave the name blank to fetch all matching records, or supply a name to filter to partners whose name matches it. Read-only and idempotent. Use to look up or list Odoo contacts/companies before acting on them.', idempotent: true },
props: {
// Properties to ask from the user, in this ask we will take number of
diff --git a/packages/pieces/community/odoo/src/lib/actions/get-record.ts b/packages/pieces/community/odoo/src/lib/actions/get-record.ts
index 0b06cfd9dbe..0e378548c8f 100644
--- a/packages/pieces/community/odoo/src/lib/actions/get-record.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/get-record.ts
@@ -12,7 +12,7 @@ export const getRecordAction = createAction({
classification: 'READ',
displayName: 'Get Record',
description: 'Get one record of any Odoo model by picking it from a list.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Reads one Odoo record of any model by ID and returns its fields, with many2one values split into an ID and a name. Use when the record is already known; to find records by criteria use a search action. Read-only and idempotent.',
diff --git a/packages/pieces/community/odoo/src/lib/actions/get-records.ts b/packages/pieces/community/odoo/src/lib/actions/get-records.ts
index 123805d0cec..06479813e3f 100644
--- a/packages/pieces/community/odoo/src/lib/actions/get-records.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/get-records.ts
@@ -11,7 +11,7 @@ export default createAction({
auth: odooAuth,
displayName: 'Custom Search and read records',
description: 'Records can be listed and filtered',
- audience: 'both',
+ audience: 'human',
aiMetadata: { description: 'Searches and reads records from any Odoo model via the XML-RPC search_read call, returning the chosen fields with optional offset/limit paging. Supply a model name and an optional Odoo domain (a list of [field, operator, value] criteria); an empty domain returns all records of the model. Read-only and idempotent. Use this generic reader when no model-specific get action fits.', idempotent: true },
props: {
// Properties to ask from the user, in this ask we will take number of
diff --git a/packages/pieces/community/odoo/src/lib/actions/post-chatter-message.ts b/packages/pieces/community/odoo/src/lib/actions/post-chatter-message.ts
index 2c2ddaaafc0..a9b582f1126 100644
--- a/packages/pieces/community/odoo/src/lib/actions/post-chatter-message.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/post-chatter-message.ts
@@ -12,7 +12,7 @@ export const postChatterMessageAction = createAction({
classification: 'WRITE',
displayName: 'Post Chatter Message',
description: 'Log a note or send a message in the chatter of a record.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Posts in the chatter of one Odoo record: an internal note (no email) or a message sent to followers. Works on models with a chatter (contacts, leads, orders, invoices, tasks). Not idempotent: each call posts another message.',
diff --git a/packages/pieces/community/odoo/src/lib/actions/run-record-action.ts b/packages/pieces/community/odoo/src/lib/actions/run-record-action.ts
index 6ffb365e78b..defec6abb2b 100644
--- a/packages/pieces/community/odoo/src/lib/actions/run-record-action.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/run-record-action.ts
@@ -12,7 +12,7 @@ export const runRecordActionAction = createAction({
classification: 'WRITE',
displayName: 'Run Record Action',
description: 'Run a button action on a record, for example confirm a quotation or post an invoice.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Calls a public business method on one Odoo record (for example action_confirm on sale.order, action_post on account.move, action_set_won on crm.lead, action_archive). Methods that return nothing are reported as success. unlink, write, update, create, name_create, load, web_save, copy, browse, sudo, with_user, with_context, with_env and private (_) methods are refused; use Delete Record, Custom Update Record, Custom Create Record or Get Record instead. This list steers you to the right action; it is not a security boundary, and Odoo access rights of the connected user still decide what the call may do. Not idempotent: most actions fail or repeat their effect when run twice.',
diff --git a/packages/pieces/community/odoo/src/lib/actions/update-record.ts b/packages/pieces/community/odoo/src/lib/actions/update-record.ts
index fc6c1fb83a3..966cdfe10bb 100644
--- a/packages/pieces/community/odoo/src/lib/actions/update-record.ts
+++ b/packages/pieces/community/odoo/src/lib/actions/update-record.ts
@@ -10,7 +10,7 @@ export default createAction({
auth: odooAuth,
displayName: 'Custom Update Record',
description: 'Update an existing record in the specified model',
- audience: 'both',
+ audience: 'human',
aiMetadata: { description: 'Overwrites fields on an existing Odoo record via the XML-RPC write call, given a model name, the target record id, and a JSON object of field names to new values. Requires a known record id (look it up first if needed). Idempotent — writing the same fields to the same id repeatedly leaves the record in the same state.', idempotent: true },
outputSchema: updateRecordOutputSchema,
props: {
diff --git a/packages/pieces/community/odoo/src/lib/common/records.ts b/packages/pieces/community/odoo/src/lib/common/records.ts
index 7660eb331b7..6a83017c33e 100644
--- a/packages/pieces/community/odoo/src/lib/common/records.ts
+++ b/packages/pieces/community/odoo/src/lib/common/records.ts
@@ -13,11 +13,7 @@ async function resolveFields({
const map = await client.fieldsGet(model);
if (fields && fields.length > 0) {
const unknown = fields.filter((name) => name !== 'id' && !(name in map));
- if (unknown.length > 0) {
- throw new Error(
- `Unknown field(s) on ${model}: ${unknown.join(', ')}. Use Get Model Fields to see the field names of this Odoo version.`,
- );
- }
+ if (unknown.length > 0) throw unknownFieldsError({ model, unknown });
return { names: withId(fields), map };
}
const names = Object.entries(map)
@@ -26,6 +22,16 @@ async function resolveFields({
return { names: withId(names), map };
}
+async function assertKnownFields({ client, model, names }: { client: OdooClient; model: string; names: readonly string[] }): Promise<void> {
+ const map = await client.fieldsGet(model);
+ const unknown = names.filter((name) => !(name in map));
+ if (unknown.length > 0) throw unknownFieldsError({ model, unknown });
+}
+
+function unknownFieldsError({ model, unknown }: { model: string; unknown: readonly string[] }): Error {
+ return new Error(`Unknown field(s) on ${model}: ${unknown.join(', ')}. Use Get Model Fields to see the field names of this Odoo version.`);
+}
+
async function resolveKnownFields({
client,
model,
@@ -220,6 +226,7 @@ function readBackReason(error: unknown): string {
export const odooRecords = {
resolveFields,
+ assertKnownFields,
resolveKnownFields,
searchPage,
readByIds,
diff --git a/packages/pieces/community/odoo/test/atomics.test.ts b/packages/pieces/community/odoo/test/atomics.test.ts
new file mode 100644
index 00000000000..770fce210bd
--- /dev/null
+++ b/packages/pieces/community/odoo/test/atomics.test.ts
@@ -0,0 +1,578 @@
+import { beforeEach, describe, expect, it } from 'vitest';
+import { createMockActionContext, OutputSchema } from '@activepieces/pieces-framework';
+import { asRecord, asRecords, auth, callsTo, evalDomain, fake, fault, fieldsOf, firstArgList, kwCalls, resetFake, route, userFault } from './fake-odoo';
+import { odoo } from '../src/index';
+import { odooAtomics } from '../src/lib/actions/atomics';
+import { odooUpdateRecords } from '../src/lib/actions/atomics/update-records';
+import { odooCreatePartner } from '../src/lib/actions/atomics/create-partner';
+import { odooNameSearch } from '../src/lib/actions/atomics/name-search';
+import { odooMarkLeadLost } from '../src/lib/actions/atomics/mark-lead-lost';
+import { odooCreateProduct } from '../src/lib/actions/atomics/create-product';
+import { odooListModels } from '../src/lib/actions/atomics/list-models';
+import { odooGetConnectionInfo } from '../src/lib/actions/atomics/get-connection-info';
+import { odooPostMessage } from '../src/lib/actions/atomics/post-message';
+import { odooFindPartners } from '../src/lib/actions/atomics/find-partners';
+import { odooListCrmStages } from '../src/lib/actions/atomics/list-crm-stages';
+import { odooPostInvoice } from '../src/lib/actions/atomics/post-invoice';
+import { odooSearchRecords } from '../src/lib/actions/atomics/search-records';
+import { odooCreateTask } from '../src/lib/actions/atomics/create-task';
+import { odooCallMethod } from '../src/lib/actions/atomics/call-method';
+import { odooDeleteRecords } from '../src/lib/actions/atomics/delete-records';
+import { odooCreateLead } from '../src/lib/actions/atomics/create-lead';
+import { odooCreateInvoice } from '../src/lib/actions/atomics/create-invoice';
+import { odooCreateRecord } from '../src/lib/actions/atomics/create-record';
+import { odooCreateSaleOrder } from '../src/lib/actions/atomics/create-sale-order';
+import { odooFindSaleOrders } from '../src/lib/actions/atomics/find-sale-orders';
+import { odooDownloadAttachment } from '../src/lib/actions/atomics/download-attachment';
+
+function schemaKeys(schema: OutputSchema | undefined): string[] {
+ return (schema?.fields ?? []).map((f) => f.key);
+}
+
+function listKeys({ schema, key }: { schema: OutputSchema | undefined; key: string }): string[] {
+ return (schema?.fields.find((f) => f.key === key)?.listItems ?? []).map((f) => f.key);
+}
+
+beforeEach(() => resetFake());
+
+describe('registration', () => {
+ const all = Object.values(odoo.actions());
+
+ it('ships 34 ai atomics with unique names and full metadata', () => {
+ expect(odooAtomics).toHaveLength(34);
+ const names = all.map((a) => a.name);
+ expect(new Set(names).size).toBe(names.length);
+ for (const a of odooAtomics) {
+ expect(a.name.startsWith('odoo_')).toBe(true);
+ expect(a.audience).toBe('ai');
+ expect(a.aiMetadata?.description?.length ?? 0).toBeGreaterThan(40);
+ expect(typeof a.aiMetadata?.idempotent).toBe('boolean');
+ expect(a.classification).toBeDefined();
+ }
+ const withoutSchema = odooAtomics.filter((a) => !a.outputSchema).map((a) => a.name);
+ expect(withoutSchema).toEqual([]);
+ });
+
+ it('demotes the 7 originals and keeps the new human actions off the agent surface', () => {
+ const human = all.filter((a) => a.audience === 'human').map((a) => a.name).sort();
+ expect(human).toEqual(
+ [
+ 'attach_file', 'create_company', 'create_contact', 'create_lead', 'create_record', 'create_sales_order',
+ 'custom_odoo_api_call', 'delete_record', 'find_invoices', 'get_contacts', 'get_record', 'get_records',
+ 'post_chatter_message', 'run_record_action', 'update_record',
+ ].sort(),
+ );
+ expect(all.filter((a) => a.audience === 'both')).toHaveLength(0);
+ });
+
+ it('has 5 polling triggers classified READ', () => {
+ const triggers = Object.values(odoo.triggers());
+ expect(triggers.map((t) => t.name).sort()).toEqual(['new_contact', 'new_lead', 'new_or_updated_record', 'new_record', 'new_sales_order']);
+ for (const t of triggers) {
+ expect(t.classification).toBe('READ');
+ expect(t.aiMetadata?.description).toBeTruthy();
+ }
+ });
+
+ it('has a mixed idempotency split', () => {
+ const t = odooAtomics.filter((a) => a.aiMetadata?.idempotent).length;
+ expect(t).toBeGreaterThan(10);
+ expect(odooAtomics.length - t).toBeGreaterThan(10);
+ });
+});
+
+describe('partial updates', () => {
+ it('update_records writes only the given keys to the given ids', async () => {
+ route({ key: 'res.partner.fields_get', handler: () => fieldsOf({ name: 'char', phone: 'char' }) });
+ route({ key: 'res.partner.write', handler: () => true });
+ const out = await odooUpdateRecords.run(actionCtx({ propsValue: { model: 'res.partner', ids: ['7', 8, 7], values: '{"phone": "+1 555"}' } }));
+ expect(callsTo({ model: 'res.partner', method: 'write' })[0].args).toEqual([[7, 8], { phone: '+1 555' }]);
+ expect(out).toEqual({ success: true, model: 'res.partner', ids: [7, 8], updated_count: 2 });
+ });
+
+ it('update_records refuses empty values and empty ids before any request', async () => {
+ await expect(odooUpdateRecords.run(actionCtx({ propsValue: { model: 'res.partner', ids: [1], values: {} } }))).rejects.toThrow(/at least one field/);
+ await expect(odooUpdateRecords.run(actionCtx({ propsValue: { model: 'res.partner', ids: [], values: { a: 1 } } }))).rejects.toThrow(/at least one ID/);
+ expect(callsTo({ model: 'res.partner', method: 'write' })).toHaveLength(0);
+ });
+
+ it('update_records refuses fields this Odoo version does not have (Odoo 19 has no mobile)', async () => {
+ route({ key: 'res.partner.fields_get', handler: () => fieldsOf({ name: 'char', phone: 'char' }) });
+ route({ key: 'res.partner.write', handler: () => fault("KeyError: 'mobile'") });
+ await expect(odooUpdateRecords.run(actionCtx({ propsValue: { model: 'res.partner', ids: [7], values: { phone: '1', mobile: '2' } } }))).rejects.toThrow(
+ 'Unknown field(s) on res.partner: mobile. Use Get Model Fields to see the field names of this Odoo version.',
+ );
+ expect(callsTo({ model: 'res.partner', method: 'write' })).toHaveLength(0);
+ });
+
+ it('create_invoice names the line whose product cannot be resolved', async () => {
+ route({ key: 'product.product.search_read', handler: () => [] });
+ await expect(
+ odooCreateInvoice.run(actionCtx({ propsValue: { partner_id: 7, lines: [{ product: 'MISSING', quantity: 1 }] } })),
+ ).rejects.toThrow('Line 1 product: no product with ID or internal reference "MISSING".');
+ expect(callsTo({ model: 'account.move', method: 'create' })).toHaveLength(0);
+ });
+
+ it('create_invoice resolves every line product in two batched calls, keeps description-only lines and caps lines at 200', async () => {
+ route({
+ key: 'product.product.search_read',
+ handler: (call) => [{ id: 31, default_code: 'FURN_7800' }, { id: 44, default_code: 'CHAIR' }, { id: 12, default_code: false }].filter((record) => evalDomain({ record, domain: firstArgList(call) })),
+ });
+ route({ key: 'account.move.create', handler: () => 90 });
+ route({ key: 'account.move.fields_get', handler: () => fieldsOf({ name: 'char' }) });
+ route({ key: 'account.move.read', handler: () => [{ id: 90, name: '/' }] });
+ const lines = [
+ { product: 'FURN_7800', quantity: 2 },
+ { description: 'Consulting', quantity: 3, price_unit: 150, tax_ids: [1] },
+ { product: 'CHAIR' },
+ { product: '12' },
+ { product: 44 },
+ ];
+ await odooCreateInvoice.run(actionCtx({ propsValue: { partner_id: 7, lines } }));
+ const lookups = callsTo({ model: 'product.product', method: 'search_read' }).map((call) => firstArgList(call));
+ expect(lookups).toEqual([[['default_code', 'in', ['FURN_7800', 'CHAIR', '12']]], [['id', 'in', [12]]]]);
+ expect(callsTo({ model: 'account.move', method: 'create' })[0].args).toEqual([
+ {
+ move_type: 'out_invoice',
+ partner_id: 7,
+ invoice_line_ids: [
+ [0, 0, { product_id: 31, quantity: 2 }],
+ [0, 0, { name: 'Consulting', quantity: 3, price_unit: 150, tax_ids: [[6, 0, [1]]] }],
+ [0, 0, { product_id: 44, quantity: 1 }],
+ [0, 0, { product_id: 12, quantity: 1 }],
+ [0, 0, { product_id: 44, quantity: 1 }],
+ ],
+ },
+ ]);
+ resetFake();
+ await expect(odooCreateInvoice.run(actionCtx({ propsValue: { partner_id: 7, lines: [{ product: 'CHAIR' }, { quantity: 1 }] } }))).rejects.toThrow('Line 2 needs a product or a description.');
+ await expect(odooCreateInvoice.run(actionCtx({ propsValue: { partner_id: 7, lines: [{ product: 'CHAIR' }, 'x'] } }))).rejects.toThrow('Line 2 must be an object.');
+ await expect(
+ odooCreateInvoice.run(actionCtx({ propsValue: { partner_id: 7, lines: Array.from({ length: 201 }, () => ({ description: 'x' })) } })),
+ ).rejects.toThrow('Add at most 200 lines per call (got 201). Split the rest into another call.');
+ expect(kwCalls()).toHaveLength(0);
+ });
+
+ it('create_partner sends only the props that were given', async () => {
+ route({ key: 'res.country.search', handler: () => [233] });
+ route({ key: 'res.partner.create', handler: () => 50 });
+ route({ key: 'res.partner.fields_get', handler: () => fieldsOf({ name: 'char', email: 'char', country_id: 'many2one' }) });
+ route({ key: 'res.partner.read', handler: () => [{ id: 50, name: 'Jane', email: '[email protected]', country_id: [233, 'United States'] }] });
+ const out = asRecord(await odooCreatePartner.run(actionCtx({ propsValue: { name: 'Jane', email: '[email protected]', phone: ' ', is_company: false, country_code: 'us' } })));
+ expect(callsTo({ model: 'res.partner', method: 'create' })[0].args).toEqual([{ name: 'Jane', email: '[email protected]', country_id: 233 }]);
+ expect(callsTo({ model: 'res.country', method: 'search' })[0].args).toEqual([[['code', '=', 'US']]]);
+ expect(out).toMatchObject({ id: 50, country_id: 233, country_id_name: 'United States', mobile: null, parent_id_name: null });
+ });
+
+ it('create_task sends x2many as replace commands and a date-only deadline', async () => {
+ route({ key: 'project.task.create', handler: () => 3 });
+ route({ key: 'project.task.fields_get', handler: () => fieldsOf({ name: 'char' }) });
+ route({ key: 'project.task.read', handler: () => [{ id: 3, name: 'T' }] });
+ await odooCreateTask.run(actionCtx({ propsValue: { project_id: 1, name: 'T', user_ids: [2, '5'], date_deadline: '2026-10-15T00:00:00Z' } }));
+ expect(callsTo({ model: 'project.task', method: 'create' })[0].args).toEqual([{ project_id: 1, name: 'T', user_ids: [[6, 0, [2, 5]]], date_deadline: '2026-10-15' }]);
+ });
+
+ it('create_lead validates probability before the request', async () => {
+ await expect(odooCreateLead.run(actionCtx({ propsValue: { name: 'x', probability: 120 } }))).rejects.toThrow(/between 0 and 100/);
+ expect(callsTo({ model: 'crm.lead', method: 'create' })).toHaveLength(0);
+ });
+});
+
+describe('version-safe calls', () => {
+ it('name_search is called positionally (args in 16-18, domain in 19)', async () => {
+ route({ key: 'res.partner.name_search', handler: () => [[7, 'Acme']] });
+ const out = await odooNameSearch.run(actionCtx({ propsValue: { model: 'res.partner', name: 'Ac', domain: [['is_company', '=', true]] } }));
+ const [call] = callsTo({ model: 'res.partner', method: 'name_search' });
+ expect(call.args).toEqual(['Ac', [['is_company', '=', true]], 'ilike', 11]);
+ expect(call.kwargs).toEqual({});
+ expect(out).toEqual({ model: 'res.partner', count: 1, has_more: false, results: [{ id: 7, name: 'Acme' }] });
+ });
+
+ it('name_search asks for one extra match to report has_more and caps the results', async () => {
+ route({ key: 'res.partner.name_search', handler: (call) => Array.from({ length: Number(call.args[3]) }, (_, i) => [i + 1, `Acme ${i}`]) });
+ const out = asRecord(await odooNameSearch.run(actionCtx({ propsValue: { model: 'res.partner', name: 'Acme', limit: 3 } })));
+ expect(callsTo({ model: 'res.partner', method: 'name_search' })[0].args[3]).toBe(4);
+ expect(out).toMatchObject({ count: 3, has_more: true });
+ expect(asRecords(out['results']).map((r) => r['id'])).toEqual([1, 2, 3]);
+ expect(Object.keys(out).sort()).toEqual(schemaKeys(odooNameSearch.outputSchema).sort());
+ });
+
+ it('mark_lead_lost tolerates the None return of action_set_lost and re-reads the lead', async () => {
+ route({ key: 'crm.lead.action_set_lost', handler: () => fault('TypeError: cannot marshal None unless allow_none is enabled') });
+ route({ key: 'crm.lead.fields_get', handler: () => fieldsOf({ name: 'char', active: 'boolean', lost_reason_id: 'many2one' }) });
+ route({ key: 'crm.lead.read', handler: () => [{ id: 4, name: 'L', active: false, lost_reason_id: [2, 'Too expensive'] }] });
+ const out = await odooMarkLeadLost.run(actionCtx({ propsValue: { lead_id: 4, lost_reason_id: 2 } }));
+ expect(callsTo({ model: 'crm.lead', method: 'action_set_lost' })[0]).toMatchObject({ args: [[4]], kwargs: { lost_reason_id: 2 } });
+ expect(out).toMatchObject({ id: 4, active: false, lost_reason_id: 2, lost_reason_id_name: 'Too expensive', won_status: null });
+ });
+
+ it('create_product maps kind to Odoo 18+ fields', async () => {
+ route({ key: 'product.template.fields_get', handler: () => fieldsOf({ name: 'char', type: 'selection', is_storable: 'boolean' }) });
+ route({ key: 'product.template.create', handler: () => 9 });
+ route({ key: 'product.template.read', handler: () => [{ product_variant_id: [19, 'Chair'] }] });
+ route({ key: 'product.product.fields_get', handler: () => fieldsOf({ name: 'char' }) });
+ route({ key: 'product.product.read', handler: () => [{ id: 19, name: 'Chair' }] });
+ const out = await odooCreateProduct.run(actionCtx({ propsValue: { name: 'Chair', kind: 'storable', list_price: 10 } }));
+ expect(callsTo({ model: 'product.template', method: 'create' })[0].args).toEqual([{ name: 'Chair', type: 'consu', is_storable: true, list_price: 10 }]);
+ expect(out).toMatchObject({ id: 19 });
+ });
+
+ it('create_product maps kind to Odoo 16/17 detailed_type and refuses storable without Inventory', async () => {
+ route({ key: 'product.template.fields_get', handler: () => ({
+ name: { type: 'char' },
+ detailed_type: { type: 'selection', selection: [['consu', 'Consumable'], ['service', 'Service']] },
+ }) });
+ await expect(odooCreateProduct.run(actionCtx({ propsValue: { name: 'Chair', kind: 'storable' } }))).rejects.toThrow(/Inventory/);
+ route({ key: 'product.template.create', handler: () => 9 });
+ route({ key: 'product.template.read', handler: () => [{ product_variant_id: [19, 'Svc'] }] });
+ route({ key: 'product.product.fields_get', handler: () => fieldsOf({ name: 'char' }) });
+ route({ key: 'product.product.read', handler: () => [{ id: 19 }] });
+ await odooCreateProduct.run(actionCtx({ propsValue: { name: 'Svc', kind: 'service' } }));
+ expect(callsTo({ model: 'product.template', method: 'create' })[0].args).toEqual([{ name: 'Svc', detailed_type: 'service' }]);
+ });
+
+ it('list_models explains the Access Rights requirement', async () => {
+ route({ key: 'ir.model.search_read', handler: () =>
+ userFault("You are not allowed to access 'Models' (ir.model) records.\n\nThis operation is allowed for the following groups:\n\t- Administration/Access Rights\n\nContact your administrator to request access if necessary.") });
+ await expect(odooListModels.run(actionCtx({ propsValue: { query: 'lead' } }))).rejects.toThrow(/odoo_get_model_fields/);
+ });
+
+ it('errors keep the whole Odoo message when there is no traceback', async () => {
+ route({ key: 'res.partner.unlink', handler: () => userFault('Record does not exist or has been deleted.\n(Record: res.partner(10,), User: 2)') });
+ await expect(odooDeleteRecords.run(actionCtx({ propsValue: { model: 'res.partner', ids: [10] } }))).rejects.toThrow(
+ 'Odoo res.partner.unlink failed: Record does not exist or has been deleted. (Record: res.partner(10,), User: 2)',
+ );
+ });
+
+ it('get_connection_info probes apps and reports installed_apps only for admins', async () => {
+ route({ key: 'res.users.fields_get', handler: () => fieldsOf({ name: 'char', company_id: 'many2one', tz: 'selection' }) });
+ route({ key: 'res.users.read', handler: () => [{ id: 2, name: 'Bot', company_id: [1, 'Acme'], tz: false }] });
+ route({ key: '*.search_count', handler: (call) => {
+ if (call.model === 'crm.lead') return 0;
+ if (call.model === 'stock.picking') return userFault("You are not allowed to access 'Transfer' (stock.picking) records.\n\nThis operation is allowed for the following groups:\n\t- Inventory/User\n\nContact your administrator to request access if necessary.");
+ return fault(`odoo.exceptions.UserError: Object ${call.model} doesn't exist`);
+ } });
+ route({ key: 'res.partner.search_count', handler: () => 0 });
+ route({ key: 'ir.module.module.search_read', handler: () =>
+ userFault("You are not allowed to access 'Module' (ir.module.module) records.\n\nThis operation is allowed for the following groups:\n\t- Administration/Settings\n\nContact your administrator to request access if necessary.") });
+ route({ key: 'res.users.has_group', handler: () => false });
+ const out = asRecord(await odooGetConnectionInfo.run(actionCtx({ propsValue: {} })));
+ expect(out).toMatchObject({
+ server_version: '18.0',
+ uid: 2,
+ user_name: 'Bot',
+ company_id_name: 'Acme',
+ tz: null,
+ has_contacts: true,
+ has_crm: true,
+ has_sales: false,
+ has_inventory: false,
+ is_admin: false,
+ installed_apps: null,
+ });
+ expect(callsTo({ model: 'crm.lead', method: 'search_count' })[0].args).toEqual([[['id', '=', 0]]]);
+ expect(callsTo({ model: 'res.users', method: 'has_group' })[0].args).toEqual([[2], 'base.group_system']);
+ });
+
+ it('get_connection_info lists apps for a non-admin who can read modules, and is_admin comes from has_group', async () => {
+ route({ key: 'res.users.fields_get', handler: () => fieldsOf({ name: 'char' }) });
+ route({ key: 'res.users.read', handler: () => [{ id: 6, name: 'Sales User' }] });
+ route({ key: '*.search_count', handler: () => 0 });
+ route({ key: 'ir.module.module.search_read', handler: () => [{ name: 'crm' }, { name: 'sale_management' }] });
+ route({ key: 'res.users.has_group', handler: () => false });
+ const out = asRecord(await odooGetConnectionInfo.run(actionCtx({ propsValue: {} })));
+ expect(out).toMatchObject({ is_admin: false, installed_apps: ['crm', 'sale_management'] });
+ });
+
+ it('get_connection_info is_admin works on Odoo 16/17, where has_group is model-level', async () => {
+ fake.state.version = { server_version: '17.0', server_serie: '17.0', protocol_version: 1 };
+ route({ key: 'res.users.fields_get', handler: () => fieldsOf({ name: 'char' }) });
+ route({ key: 'res.users.read', handler: () => [{ id: 2, name: 'Admin' }] });
+ route({ key: '*.search_count', handler: () => 0 });
+ route({ key: 'ir.module.module.search_read', handler: () => [{ name: 'crm' }] });
+ route({ key: 'res.users.has_group', handler: (call) =>
+ Array.isArray(call.args[0]) ? fault('TypeError: Users.has_group() takes 2 positional arguments but 3 were given') : call.args[0] === 'base.group_system' });
+ const out = asRecord(await odooGetConnectionInfo.run(actionCtx({ propsValue: {} })));
+ expect(out).toMatchObject({ server_serie: '17.0', is_admin: true });
+ expect(callsTo({ model: 'res.users', method: 'has_group' }).map((call) => call.args)).toEqual([[[2], 'base.group_system'], ['base.group_system']]);
+ });
+
+ it('get_connection_info is_admin is true for an admin on 18/19 and null only when has_group fails otherwise', async () => {
+ route({ key: 'res.users.fields_get', handler: () => fieldsOf({ name: 'char' }) });
+ route({ key: 'res.users.read', handler: () => [{ id: 2, name: 'Admin' }] });
+ route({ key: '*.search_count', handler: () => 0 });
+ route({ key: 'ir.module.module.search_read', handler: () => [] });
+ route({ key: 'res.users.has_group', handler: () => true });
+ await expect(odooGetConnectionInfo.run(actionCtx({ propsValue: {} }))).resolves.toMatchObject({ is_admin: true });
+ expect(callsTo({ model: 'res.users', method: 'has_group' })).toHaveLength(1);
+ resetFake();
+ route({ key: 'res.users.fields_get', handler: () => fieldsOf({ name: 'char' }) });
+ route({ key: 'res.users.read', handler: () => [{ id: 2, name: 'Admin' }] });
+ route({ key: '*.search_count', handler: () => 0 });
+ route({ key: 'ir.module.module.search_read', handler: () => [] });
+ route({ key: 'res.users.has_group', handler: () => fault('ValueError: something else') });
+ await expect(odooGetConnectionInfo.run(actionCtx({ propsValue: {} }))).resolves.toMatchObject({ is_admin: null });
+ expect(callsTo({ model: 'res.users', method: 'has_group' })).toHaveLength(1);
+ });
+
+ it('post_message normalises the message id (int on 16-18, [int] on 19)', async () => {
+ route({ key: 'res.partner.message_post', handler: () => [88] });
+ const out = await odooPostMessage.run(actionCtx({ propsValue: { model: 'res.partner', record_id: 7, body: 'Hi' } }));
+ expect(out).toEqual({ message_id: 88, model: 'res.partner', record_id: 7, message_type: 'note' });
+ expect(callsTo({ model: 'res.partner', method: 'message_post' })[0]).toMatchObject({ args: [[7]], kwargs: { body: 'Hi', message_type: 'comment', subtype_xmlid: 'mail.mt_note' } });
+ route({ key: 'res.partner.message_post', handler: () => 89 });
+ await expect(odooPostMessage.run(actionCtx({ propsValue: { model: 'res.partner', record_id: 7, body: 'Hi', kind: 'message', partner_ids: [3] } }))).resolves.toMatchObject({ message_id: 89 });
+ await expect(odooPostMessage.run(actionCtx({ propsValue: { model: 'res.partner', record_id: 7, body: 'Hi', partner_ids: [3] } }))).rejects.toThrow(/only used/);
+ });
+
+ it('find_partners leaves mobile out of the text search when the field does not exist (Odoo 19)', async () => {
+ route({ key: 'res.partner.fields_get', handler: () => fieldsOf({ name: 'char', email: 'char', phone: 'char', ref: 'char', country_id: 'many2one' }) });
+ route({ key: 'res.partner.search_read', handler: () => [] });
+ await odooFindPartners.run(actionCtx({ propsValue: { query: 'ann', country_code: 'be' } }));
+ const [call] = callsTo({ model: 'res.partner', method: 'search_read' });
+ expect(call.args[0]).toEqual([
+ '&',
+ ['country_id.code', '=', 'BE'],
+ '|', '|', '|', ['name', 'ilike', 'ann'], ['email', 'ilike', 'ann'], ['phone', 'ilike', 'ann'], ['ref', 'ilike', 'ann'],
+ ]);
+ expect(call.kwargs['fields']).not.toContain('mobile');
+ });
+
+ it('list_crm_stages uses team_ids on 19 and team_id before, and always returns team_ids', async () => {
+ route({ key: 'crm.stage.fields_get', handler: () => fieldsOf({ name: 'char', team_id: 'many2one', is_won: 'boolean' }) });
+ route({ key: 'crm.stage.search_read', handler: () => [{ id: 1, name: 'New', team_id: [3, 'Sales'], is_won: false }] });
+ const out = asRecord(await odooListCrmStages.run(actionCtx({ propsValue: { team_id: 3 } })));
+ const records = asRecords(out['records']);
+ expect(callsTo({ model: 'crm.stage', method: 'search_read' })[0].args[0]).toEqual(['|', ['team_id', '=', false], ['team_id', 'in', [3]]]);
+ expect(records[0]).toEqual({ id: 1, name: 'New', sequence: null, is_won: false, fold: null, team_ids: [3] });
+ });
+
+ it('post_invoice throws when the move is still draft (confirmation wizard)', async () => {
+ route({ key: 'account.move.action_post', handler: () => ({ type: 'ir.actions.act_window' }) });
+ route({ key: 'account.move.fields_get', handler: () => fieldsOf({ name: 'char', state: 'selection' }) });
+ route({ key: 'account.move.read', handler: () => [{ id: 1, name: '/', state: 'draft' }] });
+ await expect(odooPostInvoice.run(actionCtx({ propsValue: { invoice_id: 1 } }))).rejects.toThrow(/confirmation step/);
+ });
+
+ it('call_method passes ids first, then extra args and kwargs', async () => {
+ route({ key: 'res.partner.message_subscribe', handler: () => true });
+ const out = await odooCallMethod.run(actionCtx({ propsValue: { model: 'res.partner', method: 'message_subscribe', ids: [7], kwargs: { partner_ids: [3] } } }));
+ expect(callsTo({ model: 'res.partner', method: 'message_subscribe' })[0]).toMatchObject({ args: [[7]], kwargs: { partner_ids: [3] } });
+ expect(out).toEqual({ model: 'res.partner', method: 'message_subscribe', record_ids: [7], returned_none: false, result: true });
+ expect(Object.keys(asRecord(out)).sort()).toEqual(schemaKeys(odooCallMethod.outputSchema).sort());
+ });
+
+ it('call_method refuses generic CRUD and environment methods and names the dedicated action', async () => {
+ const refused = [
+ ['unlink', 'Use Delete Records (odoo_delete_records) to delete records.'],
+ ['write', 'Use Update Records (odoo_update_records) to change field values.'],
+ ['create', 'Use Create Record (odoo_create_record) to create records.'],
+ ['copy', 'Use Create Record (odoo_create_record) to create a new record with the values you want.'],
+ ['browse', 'Use Get Records by ID (odoo_get_records) to read records.'],
+ ['sudo', 'It changes the user or environment of the call.'],
+ ['with_user', 'It changes the user or environment of the call.'],
+ ['with_context', 'It changes the user or environment of the call.'],
+ ['with_env', 'It changes the user or environment of the call.'],
+ ['_read', 'Odoo refuses names starting with "_"'],
+ ];
+ for (const [method, message] of refused) {
+ await expect(odooCallMethod.run(actionCtx({ propsValue: { model: 'res.partner', method, ids: [7] } }))).rejects.toThrow(message);
+ }
+ expect(fake.state.calls).toHaveLength(0);
+ });
+
+ it('delete_records surfaces a second delete as an error', async () => {
+ route({ key: 'res.partner.unlink', handler: () => fault('odoo.exceptions.MissingError: Record does not exist or has been deleted.') });
+ await expect(odooDeleteRecords.run(actionCtx({ propsValue: { model: 'res.partner', ids: [7] } }))).rejects.toThrow(/MissingError/);
+ });
+});
+
+describe('create then read back', () => {
+ it('create_invoice returns the id and read_back_error when the read fails, without retrying the create', async () => {
+ route({ key: 'account.move.create', handler: () => 42 });
+ route({ key: 'account.move.fields_get', handler: () => fieldsOf({ name: 'char' }) });
+ route({ key: 'account.move.read', handler: () => fault('psycopg2.OperationalError: server closed the connection') });
+ const out = asRecord(await odooCreateInvoice.run(actionCtx({ propsValue: { partner_id: 7, lines: [{ description: 'Consulting', quantity: 1 }] } })));
+ expect(out).toMatchObject({ id: 42, name: null, partner_id: null, partner_id_name: null, read_back_error: 'Odoo account.move.read failed: psycopg2.OperationalError: server closed the connection' });
+ expect(Object.keys(out)).toEqual(schemaKeys(odooCreateInvoice.outputSchema));
+ expect(callsTo({ model: 'account.move', method: 'create' })).toHaveLength(1);
+ });
+
+ it('create_product returns the template id when the variant lookup fails, and the variant id when only the read fails', async () => {
+ route({ key: 'product.template.fields_get', handler: () => fieldsOf({ name: 'char', type: 'selection', is_storable: 'boolean' }) });
+ route({ key: 'product.template.create', handler: () => 9 });
+ route({ key: 'product.template.read', handler: () => [{ product_variant_id: false }] });
+ const noVariant = asRecord(await odooCreateProduct.run(actionCtx({ propsValue: { name: 'Chair' } })));
+ expect(noVariant).toMatchObject({ id: null, product_tmpl_id: 9, product_tmpl_id_name: null, read_back_error: 'it has no product variant' });
+ expect(Object.keys(noVariant)).toEqual(schemaKeys(odooCreateProduct.outputSchema));
+ route({ key: 'product.template.read', handler: () => [{ product_variant_id: [19, 'Chair'] }] });
+ route({ key: 'product.product.fields_get', handler: () => fault('AccessError: no read access on product.product') });
+ await expect(odooCreateProduct.run(actionCtx({ propsValue: { name: 'Chair' } }))).resolves.toMatchObject({ id: 19, read_back_error: expect.stringMatching(/AccessError/) });
+ expect(callsTo({ model: 'product.template', method: 'create' })).toHaveLength(2);
+ const readBack = odooCreateProduct.outputSchema?.fields.find((field) => field.key === 'read_back_error');
+ expect(readBack?.description).toMatch(/id is null and product_tmpl_id holds the new template ID/);
+ });
+
+ it('update_records is marked not idempotent because x2many commands add lines on every call', () => {
+ expect(odooUpdateRecords.aiMetadata).toMatchObject({ idempotent: false, description: expect.stringMatching(/\[0, 0, \{\.\.\.\}\] add lines on every call/) });
+ });
+
+ it('create_task returns the id and read_back_error when the record cannot be read', async () => {
+ route({ key: 'project.task.create', handler: () => 3 });
+ route({ key: 'project.task.fields_get', handler: () => fieldsOf({ name: 'char' }) });
+ route({ key: 'project.task.read', handler: () => [] });
+ await expect(odooCreateTask.run(actionCtx({ propsValue: { project_id: 1, name: 'T' } }))).resolves.toMatchObject({
+ id: 3,
+ name: null,
+ read_back_error: 'project.task record 3 was not found',
+ });
+ });
+
+ it('create_partner, create_record, create_lead and create_sale_order return the id and read_back_error when the read fails', async () => {
+ route({ key: 'res.partner.create', handler: () => 50 });
+ route({ key: 'crm.lead.create', handler: () => 17 });
+ route({ key: 'sale.order.create', handler: () => 12 });
+ route({ key: '*.fields_get', handler: () => fault('AccessError: no read access') });
+ route({ key: 'res.partner.read', handler: () => fault('AccessError: no read access') });
+ const cases = [
+ { action: odooCreatePartner, props: { name: 'Jane' }, id: 50 },
+ { action: odooCreateRecord, props: { model: 'res.partner', values: { name: 'Jane' } }, id: 50 },
+ { action: odooCreateLead, props: { name: 'Chairs' }, id: 17 },
+ { action: odooCreateSaleOrder, props: { partner_id: 7, lines: [{ product: 31 }] }, id: 12 },
+ ];
+ for (const { action, props, id } of cases) {
+ const out = asRecord(await action.run(actionCtx({ propsValue: props })));
+ expect(out).toMatchObject({ id, read_back_error: expect.stringMatching(/AccessError: no read access$/) });
+ expect(Object.keys(out)).toEqual(schemaKeys(action.outputSchema));
+ }
+ expect(callsTo({ model: 'res.partner', method: 'create' })).toHaveLength(2);
+ expect(callsTo({ model: 'crm.lead', method: 'create' })).toHaveLength(1);
+ expect(callsTo({ model: 'sale.order', method: 'create' })).toHaveLength(1);
+ });
+
+ it('create_record returns the id, display name and a null read_back_error when the read works', async () => {
+ route({ key: 'res.partner.create', handler: () => 50 });
+ route({ key: 'res.partner.read', handler: () => [{ id: 50, display_name: 'Jane' }] });
+ await expect(odooCreateRecord.run(actionCtx({ propsValue: { model: 'res.partner', values: { name: 'Jane' } } }))).resolves.toEqual({
+ id: 50,
+ model: 'res.partner',
+ display_name: 'Jane',
+ read_back_error: null,
+ });
+ });
+
+ it('create_record sets read_back_error when the read returns no row', async () => {
+ route({ key: 'res.partner.create', handler: () => 50 });
+ route({ key: 'res.partner.read', handler: () => [] });
+ await expect(odooCreateRecord.run(actionCtx({ propsValue: { model: 'res.partner', values: { name: 'Jane' } } }))).resolves.toEqual({
+ id: 50,
+ model: 'res.partner',
+ display_name: null,
+ read_back_error: expect.stringMatching(/res\.partner record 50 was not found$/),
+ });
+ });
+
+ it('create_partner carries a null read_back_error on success and matches its schema', async () => {
+ route({ key: 'res.partner.create', handler: () => 50 });
+ route({ key: 'res.partner.fields_get', handler: () => fieldsOf({ name: 'char', parent_id: 'many2one' }) });
+ route({ key: 'res.partner.read', handler: () => [{ id: 50, name: 'Jane', parent_id: false }] });
+ const out = asRecord(await odooCreatePartner.run(actionCtx({ propsValue: { name: 'Jane' } })));
+ expect(out).toMatchObject({ id: 50, name: 'Jane', read_back_error: null });
+ expect(Object.keys(out)).toEqual(schemaKeys(odooCreatePartner.outputSchema));
+ });
+});
+
+describe('find and download guards', () => {
+ it('find_sale_orders treats a date-only Order Date To as the whole day, and a datetime as inclusive', async () => {
+ route({ key: 'sale.order.fields_get', handler: () => fieldsOf({ name: 'char', date_order: 'datetime' }) });
+ route({ key: 'sale.order.search_read', handler: () => [] });
+ await odooFindSaleOrders.run(actionCtx({ propsValue: { date_from: '2026-09-01', date_to: '2026-09-30' } }));
+ await odooFindSaleOrders.run(actionCtx({ propsValue: { date_to: '2026-09-30T12:00:00Z' } }));
+ await odooFindSaleOrders.run(actionCtx({ propsValue: { date_to: '2026-12-31' } }));
+ const [day, datetime, yearEnd] = callsTo({ model: 'sale.order', method: 'search_read' }).map((call) => call.args[0]);
+ expect(day).toEqual([['date_order', '>=', '2026-09-01 00:00:00'], ['date_order', '<', '2026-10-01 00:00:00']]);
+ expect(datetime).toEqual([['date_order', '<=', '2026-09-30 12:00:00']]);
+ expect(yearEnd).toEqual([['date_order', '<', '2027-01-01 00:00:00']]);
+ });
+
+ it('download_attachment refuses a file over the size limit before reading its content', async () => {
+ const reads: unknown[] = [];
+ route({ key: 'ir.attachment.read', handler: (call) => {
+ reads.push(call.kwargs['fields']);
+ return [{ id: 5, name: 'big.pdf', mimetype: 'application/pdf', file_size: 30 * 1024 * 1024, type: 'binary', url: false }];
+ } });
+ await expect(odooDownloadAttachment.run(actionCtx({ propsValue: { attachment_id: 5 } }))).rejects.toThrow(
+ 'Attachment 5 (big.pdf) is 30.0 MB, larger than the 25 MB file limit of this Activepieces instance. It was not downloaded.',
+ );
+ expect(reads).toEqual([['name', 'mimetype', 'file_size', 'type', 'url']]);
+ });
+
+ it('download_attachment uses AP_MAX_FILE_SIZE_MB when it is a valid number', async () => {
+ route({ key: 'ir.attachment.read', handler: (call) => {
+ const fields = call.kwargs['fields'];
+ if (Array.isArray(fields) && fields.includes('datas')) return [{ id: 5, datas: Buffer.from('PDF').toString('base64') }];
+ return [{ id: 5, name: 'big.pdf', mimetype: 'application/pdf', file_size: 30 * 1024 * 1024, type: 'binary', url: false }];
+ } });
+ const previous = process.env['AP_MAX_FILE_SIZE_MB'];
+ try {
+ process.env['AP_MAX_FILE_SIZE_MB'] = '50';
+ await expect(odooDownloadAttachment.run(actionCtx({ propsValue: { attachment_id: 5 } }))).resolves.toMatchObject({ id: 5, name: 'big.pdf', file: 'test-file-url' });
+ process.env['AP_MAX_FILE_SIZE_MB'] = 'lots';
+ await expect(odooDownloadAttachment.run(actionCtx({ propsValue: { attachment_id: 5 } }))).rejects.toThrow(/25 MB file limit/);
+ } finally {
+ if (previous === undefined) delete process.env['AP_MAX_FILE_SIZE_MB'];
+ else process.env['AP_MAX_FILE_SIZE_MB'] = previous;
+ }
+ });
+});
+
+describe('list_models paging', () => {
+ const registry = Array.from({ length: 7 }, (_, i) => ({ id: i + 1, model: `x.model${i}`, name: `Model ${i}` }));
+
+ it('returns has_more and next_offset, and pages with offset', async () => {
+ route({ key: 'ir.model.search_read', handler: (call) => {
+ const offset = Number(call.kwargs['offset'] ?? 0);
+ return registry.slice(offset, offset + Number(call.kwargs['limit']));
+ } });
+ const first = asRecord(await odooListModels.run(actionCtx({ propsValue: { limit: 3 } })));
+ expect(first).toMatchObject({ count: 3, offset: 0, limit: 3, has_more: true, next_offset: 3 });
+ expect(first['models']).toEqual(registry.slice(0, 3).map(({ model, name }) => ({ model, name })));
+ const last = asRecord(await odooListModels.run(actionCtx({ propsValue: { limit: 3, offset: 6 } })));
+ expect(last).toMatchObject({ count: 1, offset: 6, limit: 3, has_more: false, next_offset: null });
+ const calls = callsTo({ model: 'ir.model', method: 'search_read' });
+ expect(calls[0].kwargs).toMatchObject({ offset: 0, limit: 4, order: 'model asc, id asc' });
+ expect(calls[1].kwargs).toMatchObject({ offset: 6, limit: 4 });
+ expect(Object.keys(first).sort()).toEqual(schemaKeys(odooListModels.outputSchema).sort());
+ expect(listKeys({ schema: odooListModels.outputSchema, key: 'models' })).toEqual(['model', 'name']);
+ });
+});
+
+describe('outputs match their schemas', () => {
+ it('search_records envelope keys match and binary fields are skipped by default', async () => {
+ route({ key: 'res.partner.fields_get', handler: () => fieldsOf({ name: 'char', display_name: 'char', image_1920: 'binary' }) });
+ route({ key: 'res.partner.search_read', handler: () => [{ id: 1, name: 'A', display_name: 'A' }] });
+ const out = asRecord(await odooSearchRecords.run(actionCtx({ propsValue: { model: 'res.partner' } })));
+ expect(Object.keys(out).sort()).toEqual(schemaKeys(odooSearchRecords.outputSchema).sort());
+ expect(callsTo({ model: 'res.partner', method: 'search_read' })[0].kwargs['fields']).toEqual(['id', 'name', 'display_name']);
+ });
+
+ it('find_partners items carry every schema key', async () => {
+ route({ key: 'res.partner.fields_get', handler: () => fieldsOf({ name: 'char', parent_id: 'many2one' }) });
+ route({ key: 'res.partner.search_read', handler: () => [{ id: 1, name: 'A', parent_id: false }] });
+ const out = asRecord(await odooFindPartners.run(actionCtx({ propsValue: {} })));
+ const records = asRecords(out['records']);
+ expect(Object.keys(out).sort()).toEqual(schemaKeys(odooFindPartners.outputSchema).sort());
+ for (const key of listKeys({ schema: odooFindPartners.outputSchema, key: 'records' })) {
+ expect(records[0]).toHaveProperty(key);
+ }
+ });
+
+ it('unknown requested fields fail with a pointer to get_model_fields', async () => {
+ route({ key: 'res.partner.fields_get', handler: () => fieldsOf({ name: 'char' }) });
+ await expect(odooSearchRecords.run(actionCtx({ propsValue: { model: 'res.partner', fields: ['nope'] } }))).rejects.toThrow(/odoo_get_model_fields|Get Model Fields/);
+ });
+});
+
+function actionCtx({ propsValue }: { propsValue: Record<string, unknown> }) {
+ return { ...createMockActionContext({ propsValue }), auth: auth() };
+}