Odoo Help

0

How to use get_lines in creating iteration for reports in Odoo

By
Drees Far
on 8/21/15, 8:13 AM 1,026 views

hello friends:

I want to create a new report in my OpenERP.

.PY:

class journal_paie(report_sxw.rml_parse):

  def __init__(self, cr, uid, name, context):
        super(journal_paie, self).__init__(cr, uid, name, context)
        self.localcontext.update({
        'get_lines': self.get_lines,
            'cr':cr,
            'uid':1,
            'ctxt':context,
        })

    def get_lines(self,cr,uid, context=None):
        if not context:
            context = None
    ret = []

    print ('--------------------Test Me-------------------')
        obj = self.pool.get('hr.employee')
        obj_ids = obj.search(cr, uid, [])
        res = obj.read(cr, uid, obj_ids, ['id', 'name_related','momo_matricule'], context)
    for r in res :
        if r['name_related'] != 'Administrator' :
            line_data = dict()
            line_data['name']= r['name_related']
            print "------------ journal paie get_lines "
            print r['name_related']
            ret.append(line_data)
        return ret

 

report_sxw.report_sxw('report.journal_paie_report',
                      'test.example',
                      'addons/test_example/report/journal_paie.mako', header="False",
                      parser=journal_paie)

.Mako:


<%lines = get_lines(payslip,cr,uid,'gross')

%>

%for line in lines:

<tr style='height:8.5pt'>

<td width=13 style='width:9.55pt;border:none;border-right:solid windowtext 1.0pt;

background:#DDEBF7;padding:0cm 3.5pt 0cm 3.5pt;height:8.5pt'>

<p class=MsoNormal style='margin-bottom:0cm;margin-bottom:.0001pt;line-height:

normal'><span style='font-size:8.0pt;font-family:"Arial","sans-serif";

color:black'> </span></p>

</td>

</tr>

%endfor

%endfor

How can i call a function in my mako file.

Because i want it to show me all the employees in my company.

Please help.

Regards.

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.

Register

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

1 follower(s)

Stats

Asked: 8/21/15, 8:13 AM
Seen: 1026 times
Last updated: 8/21/15, 8:13 AM