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

Export external id directly from database?

Subscribe

Get notified when there's activity on this post

This question has been flagged
3 Replies
11231 Views
Avatar
Daniel Kauffman

I am migrating a database with thousands of products. Trying to export large numbers of images using the Odoo web interface is not possible due to resource limits on the server.

How can I export the external ids and the product images directly from the Odoo database?

0
Avatar
Discard
Avatar
Daniel Kauffman
Author Best Answer

Looking at openerp/osv/orm.py in _get_external_ids() we can see that the external ids are stored in "ir_model_data" and can be tied to the models using "ir_model_data"."model" and "ir_model_data"."res_id".  So to dump product external ids and images to a CSV:

copy (select "ir_model_data"."module" || '.' || "ir_model_data"."name" as "id", encode("product_product"."image",'base64') as "image" from "product_product" left join "ir_model_data" on (("ir_model_data"."model" = 'product.product') and ("product_product"."id" = "ir_model_data"."res_id")) where ("product_product"."image" is not null)) to '/tmp/product.product.images.csv' with csv header;

Or to pipe data from the source server to another server, connect from the remote server to the source database using psql:

\copy (select "ir_model_data"."module" || '.' || "ir_model_data"."name" as "id", encode("product_product"."image",'base64') as "image" from "product_product" left join "ir_model_data" on (("ir_model_data"."model" = 'product.product') and ("product_product"."id" = "ir_model_data"."res_id")) where ("product_product"."image" is not null)) to 'product.product.images.csv' with csv header;

Alternatively, I suppose it would be possible to:

  • Export the database ids and the external ids using the Odoo web interface.
  • Export the database ids and images directly from the database.
  • Use a third-party tool and the database ids to associate the external ids with the images.
  • Upload the images to Odoo.

But exporting the external id directly, as described above, would in many cases be preferable.

Another alternative would be to script oerplib to stream data from an old database to a new database.

2
Avatar
Discard
Avatar
nesefi
Best Answer

Hi, i know this is kind of an old post but i would like to know where did you found the binaries for the images, im performing a similar export from odoo 12 and the interface export of images is broken

i used some similar queries to yours in this post but to no avail, there are no images in product_templates or product_product.

after some research i found out that for odoo 12 images are saved in ir_attachement in the field: datas_fname.

so i got this query

Select "id", "res_name", "datas_fname" from ir_attachment WHERE res_model = 'product.template' and "datas_fname" is not null;

and the result is this sample: 

https://docs.google.com/spreadsheets/u/7/d/1QR_HTSiYxUXOSl-2nS0MaDY7QHRMbux-43RhbB1eYak/edit?usp=sharing

there are no binaries in this table.

i made:

Select * from ir_attachment WHERE res_model = 'product.template' and res_field = 'image' and 'db_datas' is not null

to check all the fields from the table and got this other data set.

https://docs.google.com/spreadsheets/d/1g1zZrTLu56MU7S5O5nzg-QQtsLa8QaE7jflddnRb9Wo/edit?usp=sharing

where i got: no binaries at all

where di you got the binaries for your export?

kindly thank you very much.

0
Avatar
Discard
Avatar
Juan Carlos Fdez
Best Answer

Apologies for my ignorance but the where do you run the copy instruction? On a terminal, on postgresql, on python?

0
Avatar
Discard
Daniel Kauffman
Author

From a terminal, run psql to access your PostgreSQL database, then run the \copy command from psql. And of course test before you do anything in a production environment.

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
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