Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Export external id directly from database?

By
Daniel Kauffman
on 11/3/14, 6:37 PM 1,912 views

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?

1
Daniel Kauffman
On 11/3/14, 6:51 PM

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 11/3/14, 6:37 PM
Seen: 1912 times
Last updated: 3/16/15, 8:10 AM