Skip to content

Instantly share code, notes, and snippets.

@jaredkipe
Last active October 1, 2015 18:04
Show Gist options
  • Save jaredkipe/aac643f287445ac76e65 to your computer and use it in GitHub Desktop.
Save jaredkipe/aac643f287445ac76e65 to your computer and use it in GitHub Desktop.
Migrate res.partner images (odoo shell)
partners = env['res.partner'].search([])
for p in partners:
if not p.image:
env.cr.execute("SELECT image FROM res_partner WHERE id = " + str(p.id) + ";")
d = env.cr.fetchall()
p.image = str(d[0][0])
env.cr.commit()
# verify data is migrated then
env.cr.execute('ALTER TABLE res_partner DROP COLUMN IF EXISTS image;')
env.cr.execute('ALTER TABLE res_partner DROP COLUMN IF EXISTS image_medium;')
env.cr.execute('ALTER TABLE res_partner DROP COLUMN IF EXISTS image_small;')
env.cr.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment