This question has been flagged
1 Reply
4394 Views

Please i am using rml to create a new report in OpenERP. So that i use in my rml this code to create for each result a new td but the problem is that i got Exception: 'NoneType' object has no attribute 'tag' as an error. Here is my code:
in python:

def gross_wage_line(self, salary_line_ids) :

list=[ ]

for line in salary_line_ids :

        if line.type == 'brute' and line.afficher:

                  if line.deductible:

                         gain=0

                         retenu=float(line.subtotal_employee)

                  else:

                       gain=float(line.subtotal_employee)

                      retenu=0

               dict={'name' : line.name,

                          'base' : line.base,

                          'rate_employee' : float(line.rate_employee),

                          'gain' : gain,

                          'retenu': retenu,

                         }

                  list.append(dict)

            return list


In RML:

<section>

<para style="P1">[[ repeatIn(gross_wage_line(s.salary_line_ids),'line') ]]</para>

<blockTable colWidths="206.0,53.0,41.0,38.0,47.0,42.0,55.0" style="Table6">

<tr>

<td>

<para style="P22">[[ line['name'] ]]</para>

</td>

<td>

<para style="P24">[[ str(line['base']) ]]</para>

</td>

<td>

<para style="P13">[[ line['rate_employee'] ]]</para>

</td>

<td>

<para style="P24">[[ line['gain'] or '']]</para>

</td>

<td>

<para style="P24">[[ line['retenu'] or '' ]]</para>

</td>

<td>

<para style="P20">

<font color="white"> </font>

</para>

</td>

<td>

<para style="P20">

<font color="white"> </font>

</para>

</td>

</tr>

</blockTable>

</section>

l'error is :

"name 'gross_wage_line' is not defined" while evaluating"repeatIn(gross_wage_line(s.salary_line_ids),'line')"<type 'exceptions.ValueError'>,"name 'gross_wage_line' is not defined" while evaluating"repeatIn(gross_wage_line(s.salary_line_ids),'line')",<traceback object at 0x7f8186722320>

Can someone help me

Avatar
Discard
Best Answer

That python function should be defined in a report parser so after everything is correct and the parser is used that error will vanish. I personally recommends you to switch to QWEB based reports instead of use RML ones.

Here you can see how to define parsers (https://www.odoo.com/es_ES/forum/ayuda-1/question/how-to-define-a-custom-methods-functions-to-be-used-in-a-qweb-report-how-to-define-and-use-a-report-parser-92244), without the last report Transient model (for QWEB) you could finish your parser registration using something like this complete example:

import time

from openerp.report import report_sxw

class annual_parser(report_sxw.rml_parse):

def _get_calendar(self, string):

if string:

return string.replace("\n", ", ")

return ""

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

super(annual_parser, self).__init__(cr, uid, name, context=context)

self.localcontext.update({

'time': time,

'_get_calendar': self._get_calendar

})

report_sxw.report_sxw('report.Annual_Maintenance_Plan', 'solt.maintenance.plan', 'solt_maintenance_plan/report/solt_maintenance_plan_annual_report.rml', parser=annual_parser, header="False")


Avatar
Discard