I have this code which exports data in xml format but I need to implement the code in odoo with download option. How can i do that?
import psycopg2
CONNECT_ARGS = 'host=localhost user=postgres password=postgres dbname=agni2'
def exportPlants(outfileName):
outfile = file(outfileName, 'w') #opens file for writing
connection = psycopg2.connect(CONNECT_ARGS)
cursor = connection.cursor()
cursor.execute("select * from tbl")
rows = cursor.fetchall()
outfile.write('<?xml version="1.0" ?>\n')
outfile.write('<mydata>\n')
for row in rows:
outfile.write(' <row>\n')
outfile.write(' <name>%s</name>\n' % row[0])
outfile.write(' <desc>%s</desc>\n' % row[1])
outfile.write(' <rating>%s</rating>\n' % row[2])
outfile.write(' </row>\n')
outfile.write('</mydata>\n')
outfile.close()
exportPlants('out6')