Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
3 Odpowiedzi
5872 Widoki

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 ;)


Awatar
Odrzuć
Najlepsza odpowiedź


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) %>

Awatar
Odrzuć
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 Najlepsza odpowiedź

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'

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
lis 15
5996
2
kwi 23
9769
4
paź 16
30876
1
gru 15
4358
0
lis 15
3474