Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

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

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
configurationproject
2 Besvarelser
2633 Visninger
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
Kassér
amazigh
Forfatter

👋 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
Bedste svar

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
Kassér
Avatar
Piyush H
Bedste svar

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
Kassér
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
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
489
Subtasks on Calendar View
configuration project
Avatar
Avatar
1
dec. 24
1665
Restrict users to see all projects
configuration project v18
Avatar
Avatar
Avatar
Avatar
Avatar
4
nov. 25
344
ODOO 19 Enterprise manual
configuration accounting project
Avatar
Avatar
1
okt. 25
985
Project app and document app not linking
configuration project documents
Avatar
Avatar
2
mar. 25
2749
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

Website made with

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