Odoo Help


Not able to create simple .txt report in odoo

Akhilesh Gupta
on 4/22/16, 7:55 AM 654 views

Hi Community,

I have to create an plain simple text report. Kindly give me some advice to create this text reports.

Currently I am doing by using aeroo report but not able to fetch correct content.

Still stuck to do same.

Gustavo Hinojosa
On 4/22/16, 10:55 AM

Hi, I hopeyou help 

from openerp.osv import fields, osv

from openerp.tools.translate import _

from time import mktime

import base64

from datetime import datetime, timedelta

from dateutil import relativedelta

from cStringIO import StringIO

class ew_qr_sale_libro_ventas_wiz_qweb(osv.osv):



'start_date': fields.date('Desde la Fecha'),

'end_date': fields.date('Hasta la Fecha'),


_defaults = {

'start_date': lambda *a: time.strftime('%Y-%m-%d'),

'end_date': lambda *a: time.strftime('%Y-%m-%d'),


def range_dates_txt(self,cr,uid,filtros,context=None):

self_browse = self.browse(cr,uid,filtros[0])

filename = 'libro_ventas.txt'

fila_facilito = ""

with open(filename,"w") as file:

if filtros:

for x in range(10):

fila_facilito += 'Number '+str(x) +' Start date'+str(self_browse.start_date)+' and, end date'+ str(self_browse.start_date) +'\n'

if not fila_facilito:

fila_facilito = 'NO existen datos'

export_id = self.pool.get('txt.extended')

id_file = export_id.create(cr, uid, {'txt_file': base64.encodestring(fila_facilito), 'file_name': filename}, context=context)

return {

'view_mode': 'form',

'res_id': id_file,

'res_model': 'txt.extended',

'view_type': 'form',

'type': 'ir.actions.act_window',

'context': context,

'target': 'new',


class inventory_txt_extended(osv.osv_memory):

_name= "txt.extended"

_columns= {

'txt_file': fields.binary('Descargar formato facilito txt'),

'file_name': fields.char('Txt File', size=64),


in xml

<?xml version="1.0" encoding="utf-8"?>



<record id="view_example_wiz_qweb" model="ir.ui.view">

<field name="name">Example</field>

<field name="model">ew_qr_sale.libro_ventas.wiz.qweb</field>

<field name="arch" type="xml">

<form string="example">

<group col="4">

<field name="start_date"/>

<field name="end_date"/>



<button name="range_dates_txt" string="fechas" type="object" class="oe_highlight"/>


<button string="Cancel" class="oe_link" special="cancel"/>





<record id="action_txt_form" model="ir.actions.act_window">

<field name="name">Report txt</field>

<field name="view_id" ref="view_txt_form_extended"/>

<field name="view_type">form</field>

<field name="view_mode">form</field>

<field name="res_model">txt.extended</field>

<field name="target">new</field>




Carlos Rodriguez
On 5/10/16, 6:21 PM

Hello Gustavo, is there any way to do the same in the SaaS?

Your Answer

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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 4/22/16, 7:55 AM
Seen: 654 times
Last updated: 5/10/16, 6:21 PM