This question has been flagged

Hello! 

I try to create a report from a wizard window in Odoo v8, and i get this error:

QWebException: "'NoneType' object has no attribute '__getitem__'" while evaluating "data['fechaini']"

The code of the wizard class is:

class WizardReservas(models.TransientModel):

    _name = 'module.reporte_reservas_wizard'

    fecha_ini = fields.Date(string = 'Fecha desde')

    reservas_ids = fields.Many2many('sale.order.line','module_reserva_reporte_wizard_rel', 'reserva_id', 'reporte_id', 'Reservas')

    def reporte_alquileres_pdf(self,cr,uid,ids,context=None):

        report_data=self.browse(cr,uid,ids,context=context)        

        data={'fechaini':report_data.fecha_ini,'ids':ids}

        return self.pool['report'].get_action(cr,uid,[],'module.reportes_alquileres_wizard_qweb',data=data,context=context)

The code of the report is:

     class reportes_reservas(report_sxw.rml_parse):

    def __init__(self,cr,uid,name,context):

        super(reportes_reservas,self).__init__(cr,uid,name,context)

        self.localcontext.update({

            'get_data_reservas':self.get_data_reservas

            })

    def get_data_reservas(self,id_wizard):

        wizard_obj=self.pool.get('module.reporte_reservas_wizard')

        wizard_data=wizard_obj.browse(self.cr,self.uid,id_wizard)

        return wizard_data.reservas_ids                                            

class reporte_alquileres_wizard(models.AbstractModel):

    _name="report.module.reportes_alquileres_wizard_qweb"

    _inherit="report.abstract_report"

    _template="module.reportes_alquileres_wizard_qweb"

    _wrapped_report_class=reportes_reservas


The code of the template is:

<template id="module.reportes_alquileres_wizard_qweb" name=" Reporte de reservas con wizard">

        <t t-call="report.html_container">

                  <t t-call="report.external_layout">

                       <div class="page">

                       <h1><t t-esc="data['fechaini']"></t></h1>

                      <table class="table">

                        <thead>

                          <tr>

                            <th>Nombre</th>

                            <th>numero</th>

                            <th>orden</th>

                          </tr>

                        </thead>

                        <tbody>

                        <t t-foreach="get_data_reservas(data['ids'])" t-as="reserva">

                            <tr>

                                <td><t t-esc="reserva['product_id.name']"></t></td>

                                <td><t t-esc="reserva['id']"></t></td>

                                <td><t t-esc="reserva['order_id']"></t></td>

                            </tr>

                            

                        </t>

                        </tbody>

                    </table>

                       </div>

                  </t>

        </t>

      </template>


how can i resolve this problem?

Thanks!
Avatar
Discard