Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions ai_tool/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
=======
Ai Tool
=======

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:b0dec31c213cecc194ff875e340eb11844acb3ee0e5147864575a90b02f288bf
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fai-lightgray.png?logo=github
:target: https://github.com/OCA/ai/tree/18.0/ai_tool
:alt: OCA/ai
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/ai-18-0/ai-18-0-ai_tool
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/ai&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

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**

.. contents::
:local:

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:

.. code:: xml

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

.. code:: python

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_model``\ s we are expecting this value because we want to
do a specific action with the model.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/ai/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 <https://github.com/OCA/ai/issues/new?body=module:%20ai_tool%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Dixmit

Contributors
------------

- `Dixmit <https://www.dixmit.com>`__

- Enric Tobella

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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 <https://github.com/OCA/ai/tree/18.0/ai_tool>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions ai_tool/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from . import tools
22 changes: 22 additions & 0 deletions ai_tool/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2026 Dixmit
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Ai Tool",
"summary": """We want to generate some specific AI Tools
that might be used in other places, like MCP or native.""",
"version": "18.0.1.0.0",
"license": "AGPL-3",
"author": "Dixmit,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/ai",
"depends": [
"mail",
],
"data": [
"security/ir.model.access.csv",
"views/menu.xml",
"views/ai_tool.xml",
"data/ai_tools.xml",
],
"demo": [],
}
20 changes: 20 additions & 0 deletions ai_tool/data/ai_tools.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2026 Dixmit
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="ai.tool" id="current_date">
<field name="name">get_date</field>
<field name="description">Get the current date.</field>
<field name="model_id" ref="model_ai_tool" />
<field name="function_name">_ai_get_date</field>
<field name="kind">generic</field>
</record>

<record model="ai.tool" id="post_message">
<field name="name">post_message</field>
<field name="description">Post a message to a record.</field>
<field name="model_id" ref="model_ai_tool" />
<field name="function_name">_ai_post_message</field>
<field name="kind">generic_model</field>
</record>
</odoo>
101 changes: 101 additions & 0 deletions ai_tool/i18n/ai_tool.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * ai_tool
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: ai_tool
#: model:ir.ui.menu,name:ai_tool.ai_menu_root
msgid "AI"
msgstr ""

#. module: ai_tool
#: model:ir.actions.act_window,name:ai_tool.ai_tool_act_window
#: model:ir.model,name:ai_tool.model_ai_tool
#: model:ir.ui.menu,name:ai_tool.ai_tool_menu
msgid "AI Tool"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__create_uid
msgid "Created by"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__create_date
msgid "Created on"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__description
msgid "Description"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__display_name
msgid "Display Name"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__function_name
msgid "Function Name"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields.selection,name:ai_tool.selection__ai_tool__kind__generic
msgid "Generic"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields.selection,name:ai_tool.selection__ai_tool__kind__generic_model
msgid "Generic but requires a record to work"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__id
msgid "ID"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__kind
msgid "Kind"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool____last_update
msgid "Last Modified on"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__write_uid
msgid "Last Updated by"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__write_date
msgid "Last Updated on"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__model_id
msgid "Model"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__name
msgid "Name"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields.selection,name:ai_tool.selection__ai_tool__kind__record
msgid "Record"
msgstr ""
102 changes: 102 additions & 0 deletions ai_tool/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * ai_tool
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"

#. module: ai_tool
#: model:ir.ui.menu,name:ai_tool.ai_menu_root
msgid "AI"
msgstr ""

#. module: ai_tool
#: model:ir.actions.act_window,name:ai_tool.ai_tool_act_window
#: model:ir.model,name:ai_tool.model_ai_tool
#: model:ir.ui.menu,name:ai_tool.ai_tool_menu
msgid "AI Tool"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__create_uid
msgid "Created by"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__create_date
msgid "Created on"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__description
msgid "Description"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__display_name
msgid "Display Name"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__function_name
msgid "Function Name"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields.selection,name:ai_tool.selection__ai_tool__kind__generic
msgid "Generic"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields.selection,name:ai_tool.selection__ai_tool__kind__generic_model
msgid "Generic but requires a record to work"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__id
msgid "ID"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__kind
msgid "Kind"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool____last_update
msgid "Last Modified on"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__write_uid
msgid "Last Updated by"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__write_date
msgid "Last Updated on"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__model_id
msgid "Model"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields,field_description:ai_tool.field_ai_tool__name
msgid "Name"
msgstr ""

#. module: ai_tool
#: model:ir.model.fields.selection,name:ai_tool.selection__ai_tool__kind__record
msgid "Record"
msgstr ""
1 change: 1 addition & 0 deletions ai_tool/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import ai_tool
Loading
Loading