Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
5774 Zobrazení

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
Zrušit
Nejlepší odpověď


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
Zrušit
Autor

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

Autor

what is analytique ??? in mako!!

Autor

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

analytique is like line in your report

Autor

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

Autor Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
lis 15
5878
2
dub 23
9628
4
říj 16
30723
1
pro 15
4268
0
lis 15
3340