Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Hi - we have a crashed Openerp 7 db adn where trying to extract a pdf file from ir_attachment.dbdatas
I have tried directly via SQL but although I can retrieve something it appears to be "Gobbledygook!!
Is there a way of extracting files from the db?
copy (SELECT db_datas FROM ir_attachment WHERE name='Invoice_SAJ_2016_0964_.pdf') to '/tmp/Invoice.pdf' (FORMAT "binary");
Any advice please.
If I open each file in a text editor each file starts with "PGCOPY" - a clue maybe?
This is my reHASH of Sir 'Jaime Vasquez' above code, I tried converting his comment to an answer but kept failing.
Jaime, please forgive my poor rehash of your coding, I'm still in the "Jowels flapping in the wind, vertical acceleration learning phase" :)
conn = psycopg2.connect ("host='"+host+"' port= '"+port+"' dbname= '"+dbname+"' user= '"+user+"' password= '"+password+"'")
cur = conn.cursor()
print "Unable to connect to database."
#Invoice range to extract
for Invoice in range (768,967):
SearchString = "SELECT a.name, description, a.create_date, a.datas_fname, a.id, a.db_datas FROM ir_attachment a WHERE a.datas_fname = '"+"INVSAJ20160"+str(Invoice)+".pdf.pdf"+"';"
rows = cur.fetchall()
#Save Invocies to file
for row in rows:
f= open('C:\Users\Me\Documents\Invoices\INVSAJ20160'+str(Invoice)+'.pdf', 'wb')
#We have to decode first
if __name__ == '__main__':
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 platform 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 8/18/16, 8:49 AM|
|Seen: 394 times|
|Last updated: 1/18/17, 6:42 AM|