| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Community Apps Dependencies | Show |
| Lines of code | 1840 |
| Technical Name |
os_ai_fields |
| License | LGPL-3 |
| Website | https://github.com/alainbloos/odoo_os_ai |
| Versions | 15.0 16.0 17.0 18.0 19.0 |
Overview
OS AI Computed Fields adds an ai_compute
parameter to every Odoo field type. Write a prompt, declare dependencies, and the field is automatically
computed by an LLM — just like native compute, but powered by AI.
Fields are processed asynchronously by a background cron job (or synchronously on save), with batch processing, automatic capability routing, and full logging.
Quick Example
from odoo import fields, models
class SaleOrder(models.Model):
_inherit = 'sale.order'
ai_summary = fields.Text(
"AI Summary",
ai_compute="Summarize this sale order for {partner_id.name}: "
"lines={order_line}, total={amount_total}",
ai_compute_depends=['partner_id', 'order_line', 'amount_total'],
store=True,
)
That is all the code needed. The field computes automatically whenever the dependencies change.
Features
| ⚙ |
Works on Any Odoo Field Add ai_compute to Char, Text, Html, Integer, Float, Selection, Many2one, Many2many, Image, and Binary fields.
|
| 🕑 |
Async & Sync Modes Default: asynchronous via cron (non-blocking). Set ai_compute_async=False for immediate computation on save.
|
| 📚 |
Batch Processing Multiple records are processed in a single LLM call using structured JSON schemas. Configurable batch size (default: 40). |
| 🌐 |
Auto-Translation Set translate=True and the system generates values in all installed languages in a single LLM call.
|
| 👁 |
Vision, Image Generation & Editing Analyze images (vision), create images from text, or transform existing images. Capability routing is automatic. |
| 📄 |
PDF & Excel Document Generation Binary fields with ai_document_type='pdf' or
'xlsx' generate downloadable documents.
Uses wkhtmltopdf and openpyxl (both bundled with Odoo).
|
| 🛠 |
Resilient Cron Per-batch commits, automatic rollback on errors, and auto-stop after 3 consecutive failures. |
Supported Field Types
| Category | Field Types | Notes |
|---|---|---|
| Text | Char, Text, Html | Optional translate=True for multi-language |
| Numeric | Integer, Float | LLM output parsed and validated automatically |
| Selection | Selection | LLM picks from the field's defined options |
| Relational | Many2one, Many2many | LLM receives options filtered by domain |
| Images | Image, Binary | Vision, generation, and editing |
| Documents | Binary | With ai_document_type='pdf' or 'xlsx' |
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
ai_compute |
str | — | Prompt template with {field} placeholders |
ai_compute_depends |
list | [] | Fields that trigger recomputation when changed |
ai_compute_async |
bool | True | True: cron-based. False: compute on save |
ai_compute_batch_size |
int | 40 | Max records per LLM call |
ai_document_type |
str | None | 'pdf' or 'xlsx' for Binary fields |
Prompt Placeholders
| Placeholder | Resolves To |
|---|---|
{name} | Value of field name on the record |
{partner_id.name} | Dot-notation for related fields |
{order_line} | One2many/Many2many display names |
{image_1920} | Binary/Image fields sent as base64 to vision models |
{__date__} | Current date (YYYY-MM-DD) |
{__user__} | Current user's name |
{__company__} | Current company's name |
More Examples
Numeric scoring
ai_score = fields.Integer(
ai_compute="Rate profile completeness 0-100: "
"name={name}, email={email}, phone={phone}",
ai_compute_depends=['name', 'email', 'phone'],
store=True,
)
AI classification (Selection)
ai_type = fields.Selection(
[('prospect', 'Prospect'),
('customer', 'Customer'),
('supplier', 'Supplier')],
ai_compute="Classify {name}: vat={vat}, "
"job={function}, company={parent_id.name}",
ai_compute_depends=['name', 'vat', 'function', 'parent_id'],
store=True,
)
Vision — describe an image
ai_description = fields.Text(
ai_compute="Describe this photo: {image_1920}",
ai_compute_depends=['image_1920'],
store=True,
)
PDF and Excel documents
ai_report = fields.Binary(
"Report (PDF)",
ai_document_type='pdf',
ai_compute="Generate an HTML report for {name}",
ai_compute_depends=['name', 'email', 'phone'],
store=True,
)
Configuration
- Install OS AI Base first (pulled automatically as a dependency).
- Configure at least one AI provider in Settings > Technical > OS AI > AI Providers (Developer Mode required).
- Optionally adjust the system prompt in Settings > OS AI Fields.
- The background cron runs every 5 minutes by default. Adjust in Settings > Technical > Automation > Scheduled Actions.
Technical Details
| Technical Name | os_ai_fields |
| License | LGPL-3 |
| Dependencies | os_ai |
Demo Module
Install AI Fields Demo
(os_ai_fields_demo)
in a test database to see 15 working examples of AI-computed fields on the Contact form,
covering text, numeric, selection, relational, image, and document field types.
Developed by Alain Bloos — GitHub
Please log in to comment on this module