Skip to Content
Menu
This question has been flagged

Hello everybody!

Please guys who can help me know how after defining a function in my python file can i call  it in a mako file to create iteration in a report.

Need an answer friends.

Please who can clarify this point please.

Regards and thanks a lot ;)


Avatar
Discard
Best Answer


Example:

the python function:

def compta_fct_budget_struct_sum(self, cr, uid, ids, budget_id, struct, ca_ids,periodedu,periodeau, context=None):

return sum

Mako call:

<% budget_somme = analyique.compta_fct_budget_struct_sum(budget_id,strct.id,[[ca.id]],periodedu,periodeau) %>

Avatar
Discard
Author

Thanks a lot for you answer friend. But, please o, the mako file i make ${line.?????} in a td ??

for example if you want to show the value of budget_somme in a TD: ${budget_somme} Please don't forget to mark my answer as a valide answer

Author

what is analytique ??? in mako!!

Author

Dont worry if that works for me i will make it valide i promise ;)

analytique is like line in your report

Author

I have tried it but i got that error please help please

Author Best Answer

Here is my python function:


def get_lines(self, payslip,cr,uid, context=None):

ret = []

obj = self.pool.get('hr.employee')

obj_ids = obj.search(cr, uid, [])

res = obj.read(cr, uid, obj_ids, ['id'], context)

for r in res :

if r['name_related'] != 'Administrator' :

line_data = dict()

line_data['name']= r['name_related']

print r['name_related']

ret.append(line_data)

return ret

And in my mako:

%for obj in objects:

<% lines = obj.get_lines(payslip) %>
%for line in lines:
 <tr style='height:20.65pt'>
  <td width=31.9 style='width:31.9pt;border:none;border-bottom:solid windowtext 1.0pt;
  background:#FCE4D6;padding:0cm 3.5pt 0cm 3.5pt;height:14.65pt'>
  <p class=MsoNormal align=center style='margin-bottom:0cm;margin-bottom:.0001pt;
  text-align:center;line-height:normal'><b><span style='font-size:8.0pt;
  font-family:"Arial","sans-serif";color:black'>Nom Employé</span></b></p>
  </td>


  <td width=31.9 style='width:31.9pt;border:none;border-bottom:solid windowtext 1.0pt;
  background:#FCE4D6;padding:0cm 3.5pt 0cm 3.5pt;height:14.65pt'>
  <p class=MsoNormal align=center style='margin-bottom:0cm;margin-bottom:.0001pt;
  text-align:center;line-height:normal'><b><span style='font-size:8.0pt;
  font-family:"Arial","sans-serif";color:black'> ${line}</span></b></p>
  </td>

 </tr>

%endfor

%endfor

And i get this:

AttributeError: 'Undefined' object has no attribute 'get_lines'

Avatar
Discard
Related Posts Replies Views Activity
1
Nov 15
5002
2
Apr 23
8523
4
Oct 16
29680
1
Dec 15
3595
0
Nov 15
2580