Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyectos
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

[Odoo V12] How to use OpenAI with Odoo 12 (Python 3.6+ required)?

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
configurationproject
2 Respuestas
2698 Vistas
Avatar
amazigh

Hi everyone,

I'm currently working on a project with Odoo 12 Community, and I would like to integrate OpenAI's API (e.g., to generate reports or summaries based on notes in models).

However, I'm facing a compatibility issue:

Odoo 12 uses Python 3.5, but the official openai Python library now requires Python 3.6 or higher.

Has anyone successfully used the OpenAI API with Odoo 12?

What would be the best approach to make it work?

  • Is there a way to upgrade Python in an Odoo 12 environment without breaking compatibility? 

Any advice, examples, or best practices would be greatly appreciated!

Thanks in advance.

0
Avatar
Descartar
amazigh
Autor

👋 Hi everyone,

Huge thanks to @Piyush H and @Desk Enterprise for your clear and helpful answers!

✅ I followed your advice and used direct HTTP requests with requests, which works perfectly with Odoo 12 (Python 3.5).

This approach is clean, effective, and fully compatible—no need to upgrade Python or use the official OpenAI library.

🔥 For anyone wondering: using the API directly without the openai package is a great workaround for legacy environments.

Thanks again and best of luck to all of you!

Amazigh

Avatar
D Enterprise
Mejor respuesta

Hii,

Use direct HTTP requests instead of the official openai Python library.

You can integrate OpenAI API using requests, which works with Python 3.5.
Example:
import requests

import json


def call_openai(prompt):

    headers = {

        "Authorization": "Bearer YOUR_OPENAI_API_KEY",

        "Content-Type": "application/json",

    }

    data = {

        "model": "gpt-3.5-turbo",

        "messages": [{"role": "user", "content": prompt}],

        "temperature": 0.7,

    }

    response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, data=json.dumps(data))

    result = response.json()

    return result['choices'][0]['message']['content']

 i Hope It Is help full

0
Avatar
Descartar
Avatar
Piyush H
Mejor respuesta

Since Odoo 12 runs on Python 3.5 and the official openai package requires Python 3.6+, here are your best options:

Option 1: Use OpenAI API Directly (Recommended)

Instead of using the official Python package, make direct HTTP requests to the OpenAI API:

  1. Install requests package (works with Python 3.5):
    bash
    pip install requests
  2. Create a custom module with this basic implementation:
    python
    import requests
    import json
    from odoo import models, fields, api
    
    class OpenAIIntegration(models.Model):
        _name = 'openai.integration'
    
        def call_openai(self, prompt):
            api_key = "your-api-key"  # Store this securely in config parameters
            headers = {
                "Authorization": f"Bearer {api_key}",
                "Content-Type": "application/json"
            }
            data = {
                "model": "text-davinci-003",  # or newer model
                "prompt": prompt,
                "temperature": 0.7,
                "max_tokens": 256
            }
            
            try:
                response = requests.post(
                    "https://api.openai.com/v1/completions",
                    headers=headers,
                    data=json.dumps(data)
                return response.json().get('choices')[0].get('text')
            except Exception as e:
                return f"Error: {str(e)}"
Option 2: Use Older OpenAI Package Version

Try version 0.10.8 (last version supporting Python 3.5):

bash

pip install openai==0.10.8
Option 3: Docker Workaround (Advanced)

Run a separate Python 3.6+ microservice that handles OpenAI calls and communicates with Odoo via:

  • REST API
  • XML-RPC
  • Message queue (RabbitMQ)
Implementation Example

To generate report summaries from notes:

python

@api.model
def generate_summary(self, note_id):
    note = self.env['note.note'].browse(note_id)
    prompt = f"Summarize this business note in 3 bullet points:\n\n{note.name}"
    summary = self.call_openai(prompt)
    note.write({'summary': summary})
Important Notes
  1. Security: Never hardcode API keys - use ir.config_parameter
  2. Error Handling: Add proper timeouts and retries
  3. Rate Limits: Implement throttling (OpenAI has strict limits)
  4. Cost Control: Monitor token usage to avoid surprise bills

Alternative Approach

Consider upgrading to Odoo 13+ (Python 3.6+) if possible, as this will give you:

  • Better Python version support
  • Official OpenAI package compatibility

Security updates

🚀 Did This Solve Your Problem?

If this answer helped you save time, money, or frustration, consider:

✅ Upvoting (👍) to help others find it faster

✅ Marking as "Best Answer" if it resolved your issue

Your feedback keeps the Odoo community strong! 💪

(Need further customization? Drop a comment—I’m happy to refine the solution!)

0
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
How to automatically create only one project (from template) for a Sale Order, even if it has multiple service lines?
configuration project
Avatar
Avatar
1
nov 25
542
Subtasks on Calendar View
configuration project
Avatar
Avatar
1
dic 24
1684
Restrict users to see all projects
configuration project v18
Avatar
Avatar
Avatar
Avatar
Avatar
4
nov 25
447
ODOO 19 Enterprise manual
configuration accounting project
Avatar
Avatar
1
oct 25
1074
Project app and document app not linking
configuration project documents
Avatar
Avatar
2
mar 25
2784
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y estar totalmente integrado.

Sitio web hecho con

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now