Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

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

Subscribe

Get notified when there's activity on this post

This question has been flagged
configurationproject
2 Replies
2600 Views
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
Discard
amazigh
Author

👋 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
Best Answer

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
Discard
Avatar
Piyush H
Best Answer

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

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

Sign up
Related Posts Replies Views Activity
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
448
Subtasks on Calendar View
configuration project
Avatar
Avatar
1
Dec 24
1648
Restrict users to see all projects
configuration project v18
Avatar
Avatar
Avatar
Avatar
3
Nov 25
264
ODOO 19 Enterprise manual
configuration accounting project
Avatar
Avatar
1
Oct 25
920
Project app and document app not linking
configuration project documents
Avatar
Avatar
2
Mar 25
2707
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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