Skip to content

Odoo 19 AI Modules

Odoo 19 AI Modules

Create and Configure Your First AI Agent

Welcome to this step-by-step tutorial on Odoo 19 AI modules. In this guide, we will walk you through setting up your environment, installing required extensions, creating an AI agent, and connecting APIs. Moreover, we will provide clear instructions, best practices, and troubleshooting tips. Therefore, you can harness the power of AI directly inside Odoo without confusion.



Introduction to Odoo 19 AI Modules

First, you need to grasp what Odoo 19 AI modules bring to your business processes. Next, you will see that Odoo now offers built-in AI agents, vector stores, and API connectors. Moreover, these modules simplify tasks like summarizing documents, answering FAQs, and automating workflows. Therefore, by the end of this tutorial, you will have a working AI agent inside Odoo 19 CE or EE.


Prerequisites and Environment Setup

Before diving in, ensure you meet the following requirements:

  • Odoo 19 Installation
    You must run Odoo 19 (Community or Enterprise) on a Linux server or your local machine.
  • PostgreSQL 17+
    Moreover, you need PostgreSQL version 17 or higher to support the PGVector extension.
  • PGVector Extension
    Install the PGVector extension if you plan to use your database as a vector store.
  • Developer Mode
    Activate developer mode in Odoo to reveal advanced settings and menu items.
  • Python Dependencies
    Use a virtual environment and run:
  pip install odoo19-addon-ai odoo19-addon-ai-vector
  • API Keys
    Obtain your OpenAI key (or Anthropic, etc.) and note it for configuration.

Once you have these items, you can proceed to enable AI features.


Understanding Odoo 19 AI Framework

Odoo 19 AI Modules Overview

First, the Odoo 19 AI framework introduces two key addons:

  1. AI Core
    This module delivers the base models and the agent scheduler.
  2. AI Tools
    This addon offers built-in tools like ChatGPT, PDF Reader, and Web Search.

Consequently, you can mix and match tools to create powerful agents.

Key Concepts and Components

  • Agent
    An AI entity that executes chains of tools and prompts.
  • Tool
    A single functionality, such as calling a chat model or fetching a webpage.
  • Vector Store
    A database that holds embeddings for semantic search.
  • Server Action
    A clickable action in Odoo that triggers your agent.

Step 1: Enable Developer Mode and AI Features

First, log in to your Odoo instance as an administrator. Then follow these steps:

  1. Activate Developer Mode
  • Click your user dropdown.
  • Select Settings.
  • Click Activate the developer mode link at the bottom.
  1. Install AI Addons
  • Go to Apps → Update Apps List.
  • Search for AI Core and AI Tools.
  • Click Install on both modules.
  1. Verify Installation
  • Check that you see a new menu AI Agents under Settings.
  • Confirm no errors appear in the logs.

Now, you have enabled the base for Odoo 19 AI modules and you can proceed.


Step 2: Install and Configure Vector Database

Choosing Your Vector Store

First, you must pick between two options:

  • PGVector on PostgreSQL
  • External Vector Database (e.g., Weaviate)

If you choose PGVector, continue below; otherwise skip to External Setup.

H2: PGVector Installation

  1. Install Extension
   sudo -u postgres psql -c "CREATE EXTENSION IF NOT EXISTS vector;"
  1. Grant Access
   sudo -u postgres psql -c "GRANT ALL ON EXTENSION vector TO odoo;"
  1. Restart Odoo
   sudo systemctl restart odoo

H3: External Vector Database

  1. Deploy Weaviate (or your service of choice).
  2. Note the Endpoint URL and API key.
  3. Configure in Odoo
  • Go to Settings → AI → Vector Stores.
  • Click Create.
  • Choose Weaviate and fill in credentials.

Once you complete this step, your agent can store embeddings.


Step 3: Create Your First AI Agent

H2: Define a New Agent Record

  1. Navigate to Settings → AI Agents.
  2. Click New.
  3. Fill in:
  • Name: “Support Bot”
  • Description: “Answer customer questions”
  • Vector Store: Select your PGVector or Weaviate record
  1. Click Save.

H3: Configure Agent Settings

  • Max Tokens: 512
  • Temperature: 0.2 (for reliable answers)
  • Model: Choose gpt-4 or custom

Consequently, you establish an agent ready to accept tools and actions.


Step 4: Connect External APIs

First, you must register your API keys as system parameters.

  1. Go to Settings → Technical → System Parameters.
  2. Click Create and set:
  • Key: openai.api_key
  • Value: your OpenAI key
  1. Repeat for any other provider, such as:
  • anthropic.api_key
  • huggingface.api_key

Next, test your configuration:

curl https://api.openai.com/v1/models \
  -H "Authorization: Bearer $OPENAI_API_KEY"

Thus, you verify that Odoo can call the service.


Step 5: Add Tools to Your AI Agent

H2: Attach ChatGPT Tool

  1. Open your agent record.
  2. Under Tools, click Add a line.
  3. Choose ChatGPT.
  4. Set Name: “Chat Helper”.
  5. Save.

H3: Attach PDF Reader Tool

  • Click Add a line again.
  • Choose PDF Reader.
  • Name it “Doc Reader”.
  • Save.

Consequently, your agent can now summarize documents and chat.


Step 6: Define a Server Action for AI

First, create an Odoo server action that kicks off your agent.

  1. Go to Settings → Technical → Actions → Server Actions.
  2. Click Create.
  3. Fill in:
  • Action Name: “Run Support Bot”
  • Model: res.partner (for customers)
  • Action To Do: Execute Python Code
  1. In the code box, insert:
   record = env[context['active_model']].browse(context['active_id'])
   agent = env['ai.agent'].search([('name', '=', 'Support Bot')], limit=1)
   response = agent.run({
       'input': record.comment or record.name,
       'context': {'partner_id': record.id}
   })
   action = {
       'type': 'ir.actions.client',
       'tag': 'display_notification',
       'params': {
           'title': 'AI Response',
           'message': response.get('text'),
           'type': 'success',
       }
   }
   return action
  1. Click Save.

Next, add a button in the partner form view:

<button name="%(action_id)d" 
        string="Ask AI"  
        type="action"  
        class="btn-primary"/>

Therefore, users can click “Ask AI” to get instant answers.


Step 7: Integrate Chat UI into Odoo

H2: Add Chat Widget to Your Dashboard

First, install the frontend addon:

pip install odoo19-chat-widget

Next, enable it:

  1. Go to Apps → Update Apps List.
  2. Find Chat Widget.
  3. Click Install.

Finally, include the widget in your template:

<template id="assets_frontend" inherit_id="web.assets_frontend">
  <xpath expr="." position="inside">
    <script src="/chat_widget/static/js/chat.js"></script>
    <link href="/chat_widget/static/css/chat.css" rel="stylesheet"/>
  </xpath>
</template>

Consequently, your users can chat directly on the website.


Step 8: Test and Iterate Your AI Agent

First, validate your setup:

  1. Open a customer record.
  2. Click Ask AI.
  3. Enter a sample question.
  4. Observe the response notification.

Next, refine prompts:

  • Adjust the temperature for more creative answers.
  • Change max tokens for longer outputs.

Moreover, monitor logs in Settings → Technical → Logs to catch errors.


Advanced Tuning of AI Modules

H2: Customize Prompt Templates

  1. Go to Settings → AI → Prompt Templates.
  2. Click Create.
  3. Define:
  • Name: “Support Prompt”
  • Template: You are a customer support assistant. When user asks: {{ input }}, answer concisely.
  1. Save and attach to your tool.

H3: Chain Multiple Tools

  • Combine PDF Reader and ChatGPT to answer document-based queries.
  • For example, build a chain:
  1. Extract text.
  2. Generate summary.
  3. Answer question based on summary.

Troubleshooting Common Issues

H2: “Agent not found” Error

  • Cause: You used the wrong agent name in server action.
  • Fix: Verify the exact agent record name under Settings → AI Agents.

H3: “API Key Invalid”

  • Cause: You set the system parameter incorrectly.
  • Fix: Go to Settings → Technical → System Parameters and correct the key.

Best Practices for Odoo AI Integration

H2: Secure Your API Keys

First, never hard-code keys in code. Then, always use system parameters.

H3: Monitor Usage and Costs

  • Track token usage in OpenAI dashboard.
  • Set limits in Odoo: Settings → AI → Rate Limits.

H4: Document Your Agents

Keep a README in your custom module:

# Support Bot Agent

- Tools: ChatGPT, PDF Reader  
- Prompt: Support Prompt  
- Model: gpt-4, temperature=0.2

Conclusion and Next Steps

Throughout this tutorial, you learned to:

  1. Enable Odoo 19 AI modules features.
  2. Configure vector stores.
  3. Create and customize an AI agent.
  4. Connect APIs and add tools.
  5. Define server actions and chat UI.

Consequently, you can now build advanced AI assistants inside Odoo. Next, explore integrating more tools like web scrapers or custom ML models.


Further Resources

Feel free to experiment, adjust settings, and share your feedback in the Odoo community forums.


Discover more from teguhteja.id

Subscribe to get the latest posts sent to your email.

Leave a Reply

WP Twitter Auto Publish Powered By : XYZScripts.com