How to Handle CSV File Operations in Odoo 18 – Import, Export & Automate Like a Boss

Ever wrestled with CSV files in Odoo? This guide breaks it down so you can manage data like a pro.

Working with data is part of every Odoo project. Whether you’re importing product lists, exporting sales orders, or syncing records — CSV files are your go-to format. But one wrong column, and boom — you’re stuck with confusing errors.

Let’s simplify the whole process in Odoo 18.

📂 What Are CSV File Operations in Odoo?

CSV (Comma Separated Values) files help you import and export bulk data in Odoo. They’re useful for:

  • Migrating records
  • Updating fields in bulk
  • Integrating with third-party systems
  • Creating backups

Odoo supports CSV for almost every model — from inventory to accounting.

📤 How to Import CSV Files in Odoo 18

Step 1: Go to the Model View

Let’s say you want to import Products:

  • Navigate to Inventory > Products
  • Click on the ⚙️ icon in the top-right
  • Choose Import Records

Step 2: Prepare Your CSV

Your CSV should have:
 ✅ Field headers like name, default_code, list_price
 ✅ Correct formatting (especially dates, relations)
 ✅ No empty columns or merged cells

Use Odoo’s export feature to get a sample structure.

Step 3: Upload and Validate

  • Select your file
  • Map the columns to Odoo fields
  • Hit Test Import first (always)
  • If clean, click Import

💡 Pro Tip: For relational fields like Category, use external IDs or full names. Example: product.product_category_all.

📦 How to Export Data to CSV

Need to extract data from Odoo? Here’s how:

Step 1: Open the View You Need

For example, go to Sales > Orders

Step 2: Select Records

  • Use filters to find what you need
  • Tick the checkboxes or select all

Step 3: Export

  • Click Action > Export
  • Choose between Export All Fields or select manually
  • Export format: .csv

💡 Use external IDs for importing later. Odoo will match them during updates.

🛠️ Automate CSV Operations with Scheduled Actions

Tired of manual imports/exports? Automate with Odoo’s backend power.

Scenario: Auto-import daily stock updates

  1. Create a custom script in Python
  2. Use ir.cron to schedule it
  3. Script reads CSV from a folder or FTP
  4. Parses it and updates stock levels

Example snippet:

python

import csv

def import_products(self):

    with open(‘/tmp/products.csv’, newline=”) as csvfile:

        reader = csv.DictReader(csvfile)

        for row in reader:

            self.env[‘product.product’].create({

                ‘name’: row[‘Product Name’],

                ‘list_price’: row[‘Price’]

            })

This is perfect for integrations with external systems like Shopify, Amazon, or ERPs.

🚨 Common Errors & Fixes

Missing required field → Always check mandatory fields like name
Unknown external ID → Use correct external references
Encoding issues → Save your CSV in UTF-8
Wrong data type → Ensure numbers, dates, booleans match Odoo’s expected format

Fix these before re-importing to save tons of time.

🔐 Best Practices for CSV Handling in Odoo

✅ Export first → Use it as a template
✅ Keep backups of original files
✅ Use Google Sheets for collaboration
✅ Never upload production data without testing on staging
✅ Use id fields to update instead of creating duplicates

💬 Final Words – Data is Power (If You Handle it Right)

CSV files might seem simple, but in Odoo, they’re your gateway to mass operations. Done right, they save you time, reduce errors, and automate repetitive work.

If you need help setting up automated imports or resolving CSV nightmares, I’m just a message away.


Follow me on LinkedIn for more latest updates