Ai Tool
This technical module provides the base infrastructure for defining AI tools in Odoo. It allows other modules to register callable functions as AI tools, which can then be used by MCP servers, automation flows, or any AI-native integration.
Table of contents
Usage
This module is technical, however, it adds some specific functions that might be used in glue modules.
For example, if we want to add on sales a functionality to find the sales on a period, we should do:
<odoo>
<record model="ai.tool" id="total_sale_order_tool">
<field name="name">total_sale_order</field>
<field
name="description"
>Calculate the total amount of sale orders within a date range and optionally for a specific customer.</field>
<field name="model_id" ref="model_sale_order" />
<field name="function_name">_mcp_total_sale_order</field>
</record>
</odoo>
from odoo.addons.ai_tool.tools import aitool
class SaleOrder(models.Model):
_inherit = "sale.order"
@aitool(
input_schema={
"start_date": {"type": "date"},
"end_date": {"type": "date"},
"customer_id": {"type": "integer"},
},
required_inputs=["start_date", "end_date"],
output_schema={
"amount_total": {"type": "number"},
},
)
def _mcp_total_sale_order(self, start_date, end_date, customer_id=None):
domain = [("date_order", ">=", start_date), ("date_order", "<=", end_date)]
if customer_id:
domain.append(("partner_id", "=", customer_id))
orders = self.read_group(domain, ["amount_total"], [])
return {
"amount_total": (orders[0]["amount_total"] or 0) if orders else 0,
}
Be aware that this kind of elements must allways return a dict. All the elements will be defined in output_schema.
Also, for the signature of the functions, all fields must be in the inputs with the exception of record. This argument is protected and is used to define integrations with automation. This argument is required in generic_model and record tools.
On generic_models we are expecting this value because we want to do a specific action with the model.
Bug Tracker
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.
Do not contact contributors directly about support or help with technical issues.
Credits
Contributors
-
Enric Tobella
-
Matteo Boscolo <matteo.boscolo@omniasolutions.eu>
Maintainers
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
This module is part of the OCA/ai project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Metadata
Release files for odoo-addon-ai-tool 19.0.1.0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| odoo_addon_ai_tool-19.0.1.0.0.2-py3-none-any.whl | Python 3 | none | any | Details for odoo_addon_ai_tool-19.0.1.0.0.2-py3-none-any.whl |
Release files / odoo_addon_ai_tool-19.0.1.0.0.2-py3-none-any.whl
| Download URL | odoo_addon_ai_tool-19.0.1.0.0.2-py3-none-any.whl |
|---|---|
| Size | 30.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
39cd579b238f5188af2e69f9a821ba4c194e8a58050529db216c17a3867477e2
|
|
BLAKE2b-256 checksum How to use checksums |
54f1f37bc66358742e5de8d73fb841a537369b4e8946c6a7e0d41f8d7e92a488
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for odoo-addon-ai-tool 19.0.1.0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.