Skip to content

Instantly share code, notes, and snippets.

@rvalyi
Created May 24, 2017 16:58
Show Gist options
  • Save rvalyi/64ff34b57742ced49ae2f8562775aed8 to your computer and use it in GitHub Desktop.
Save rvalyi/64ff34b57742ced49ae2f8562775aed8 to your computer and use it in GitHub Desktop.
convert Odoo attachments to filestore
# see https://www.odoo.com/forum/help-1/question/where-are-document-attachments-stored-529
session.open()
attachment_obj=session.env['ir.attachment']
def migrate_attachment(att):
# 1. get data
data = att.read(['datas'])['datas']
# 2. Re-Write attachment
#a = attachment_obj.write([att_id], {'datas': data})
pass
attachments = attachment_obj.search([('db_datas','=',True)]) #attachment_obj.search([('store_fname','=',False)])
cnt = len(att_ids)
i = 0
for att in attachments:
#att = attachment_obj.read(id, ['datas','parent_id'])
migrate_attachment(att)
print 'Migrated ID %d (attachment %d of %d)' % (att.id, i, cnt)
i = i + 1
session.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment