Odoo Help

Welcome!

This community 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.

0

Retrieving all records from a table with mako templates

By
Santiago J. Said
on 4/30/14, 10:41 AM 1,119 views

Hi folks, I want to know how can i get all records of a table from my openerp 7 with mako templates(to show it in my report). As far I know, in my mako template i have an iterable called objects which is a browse_record(suri.flete.items_recorrida, 1).

My question is how can i get all the records of the table "suri.flete.items_recorrida", and then only show in the report the items which values en_recorrida and finalizado are False.

In my mako template(flete_rep_webkit.mako):

    %for item in objects:
        <tr>
            <td>${item.descripcion}</td>
            <td>${item.origen.nombre}(${item.origen.direccion},${item.origen.localidad})</td>
            <td>${item.destino.nombre}, (${item.destino.direccion},${item.destino.localidad})</td>
        </tr>
    %endfor

In my parser .py file(flete_webkit.py)

import time
from report import report_sxw
from osv import osv

class flete_webkit(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(flete_webkit, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({
            'time': time,
            'cr':cr,
            'uid': uid,
        })        

report_sxw.report_sxw('report.webkit.flete_items_recorrida',
                           'suri.flete.items_recorrida', 
                           '/suri/flete/report/flete_rep_webkit.mako',
                           parser=flete_webkit)

In my view

<report auto="False" id="flete_webkit" model="suri.flete.items_recorrida" name="webkit.flete"  file="suri/flete/report/flete_rep_webkit.mako" string="Reporte prueba" report_type="webkit" />

In my .py file (flete.py)

class items_recorrida(osv.osv):        
    _name = "suri.flete.items_recorrida"
    _columns = {
        'name' : fields.related('descripcion', 'name', type="many2one", relation="suri.flete.items_recorrida", string='Descripcion',context="{'form_view_ref' : 'suri.flete.formulario_flete_items_recorrida', 'tree_view_ref' : 'suri.flete.arbol_flete_items_recorrida'}"),
        'estado' : fields.boolean('Estado', required=True),
        'descripcion' : fields.char('Descripcion', size=128, required = True),
        'documentacion' : fields.char('Documentacion', size=128, required = False),
        'origen': fields.many2one('res.partner.sedes','Origen', required=True),#FK->res.partner.sedes
        'destino': fields.many2one('res.partner.sedes','Destino', required=True),#FK->res.partner.sedes
        'pedido_por': fields.many2one('res.users','Pedido por', required=True),#FK->res.users
        'id_flete': fields.many2one('suri.flete.recorrida','Numero de flete',required=False),#FK->suri.flete.recorrida        
        'nota': fields.char('Nota',size=128,required=False),
        'proyecto': fields.many2one('suri.proyectos.proyecto','Proyecto',required=False),#FK->suri.proyectos.proyecto
        'dimension': fields.char('Dimension Estimada', size=128, required = False),
        'peso': fields.char('Peso Estimado', size=128, required = False),
        'fragil': fields.boolean('Es fragil?', required=False),
        'urgente': fields.boolean('Es urgente?', required=False),
        'en_recorrida': fields.boolean('Esta en recorrida?', required=False,),
        'finalizado': fields.boolean('Esta finalizado?', required=False,) 
    }

    _defaults = {
    'en_recorrida' : False,
    'finalizado' : False,      
    }

    _rec_name = 'descripcion'

Thanks in advance.

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 4/30/14, 10:41 AM
Seen: 1119 times
Last updated: 3/16/15, 8:10 AM