This question has been flagged
3 Replies
5644 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.


Avatar
Discard
Best Answer

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):

_name="ew_qr_sale.libro_ventas.wiz.qweb"

_columns={

'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"?>

<openerp>

<data>

<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"/>

</group>

<footer>

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

or

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

</footer>

</form>

</field>

</record>

<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>

</record>

</data>

</openerp>

Avatar
Discard
Best Answer

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

Avatar
Discard