Last active
October 1, 2015 18:04
-
-
Save jaredkipe/aac643f287445ac76e65 to your computer and use it in GitHub Desktop.
Migrate res.partner images (odoo shell)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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