Skip to Content
Menu
This question has been flagged
18 Replies
7686 Views

Hi my friends!!

I am working with RML in OpenER

In fact, i am creating two loop functions.

The first is to know the size of my array and divide it by 6 as bellow:

def get_employee_taille(self, company_id, date_start, date_end, context=None):

res_list=[]

res_list2=[]

i = 0

obj2 = company_id.id

payslip_line = self.pool.get('hr.payslip')

obj_ids = payslip_line.search(self.cr, self.uid, [('date_from', '=', date_start), ('date_to', '=', date_end), ('company_id', '=', obj2)])

for res in payslip_line.read(self.cr, self.uid, obj_ids, ['id', 'employee_id'], context=False):

print res['employee_id'][1]

obj = {}

obj['name'] = res['employee_id'][1]

res_list.append(obj)

taille = len (res_list) / 6

print taille

return taille

And the second is to give the array a position start and the number of columns that it have to contain.

def get_employee_lines(self, company_id, date_start, date_end, start_position, number_of_columns, context=None):
print ('--------------------MOMO----------------------')
i = 0
res_list=[]
print ('--------------------test me----------------------')
print company_id
obj2 = company_id.id
payslip_line = self.pool.get('hr.payslip')
print payslip_line
obj_ids = payslip_line.search(self.cr, self.uid, [('date_from', '=', date_start), ('date_to', '=', date_end), ('company_id', '=', obj2)])
print obj_ids
for res in payslip_line.read(self.cr, self.uid, obj_ids, ['id', 'employee_id','seetek_worked_day','hours_overtime_100','seetek_absence_day','total_brut','retenue_source','net_payer'], context=False):
print res['employee_id'][1]
obj = {}
obj['name'] = res['employee_id'][1]
obj['matricule'] = str (res['employee_id'][0])
obj['presence'] = str (res['seetek_worked_day'])
obj['heures_sup'] = str (res['hours_overtime_100'])
obj['absence'] = str (res['seetek_absence_day'])
obj['total_brut'] = str (res['total_brut'])
obj['retenue_source'] = str ( - res['retenue_source'])
obj['net_payer'] = str (res['net_payer'])
obj['cnss_sal'] = str (res['total_brut'] * 9.18)
obj['cnss_pat'] = str (res['total_brut'] * 16.57)
obj['salaire_imposable'] = str ( -res['total_brut'] * (1-9.18))
res_list.append(obj)
print res_list
print res_list[0:2]
end_position = start_position + number_of_columns
return res_list[start_position:end_position]

Now, in my rml, i want to create a report which will give me the list of employees but with 6 employees per page.

<section>

<blockTable colwidths="150,100,100,100,100,100" style="Table1">

<section>

<para style="P7">[[ repeatIn(get_employee_taille(example.company_id,example.date_start,example.date_end), 'o') ]]</para>

<tr>

<td>

<para style="P8">NOM EMPLOYÉ</para>

</td>

<td>

<para style="P7">[[ repeatIn(get_employee_lines(example.company_id,example.date_start,example.date_end, 0, 6), 'o', 'td') ]]</para>

<para style="P7">[[ o['name'] ]]</para>

</td>

</tr>

</section>

I have tried this but it doesnt work and give me this error:

TypeError: 'int' object is not iterable

Help please help help help help

Avatar
Discard

Drees,
Are you returning the list well from py file??
if no, please check it by printing list what u r returning before return statement. and please provide that print data if possible

Author

pawan which function are you talking about the first one or the second

Author

i have changed in the first function return taille to return [taille] and when i print it i got [1]

Author

Pawan what i want to do is to print the list of employees but with two nested loop where the first one is to print 6 columns per page :/

Why are u calling that function(first one), i can't see its any use in rml/py file...
please print second function result too

Author

I have print or you this print res_list[0:6] so i have got this [{'total_brut': '1000.0', 'name': u'ABDELWAHED RIHENE', 'presence': '0', 'salaire_imposable': '8180.0', 'net_payer': '442.558', 'absence': '0', 'retenue_source': '465.642', 'cnss_sal': '9180.0', 'cnss_pat': '16570.0', 'matricule': '2', 'heures_sup': '0'}, {'total_brut': '1000.0', 'name': u'ADNANE BEN YOUSSEF', 'presence': '0', 'salaire_imposable': '8180.0', 'net_payer': '442.558', 'absence': '0', 'retenue_source': '465.642', 'cnss_sal': '9180.0', 'cnss_pat': '16570.0', 'matricule': '4', 'heures_sup': '0'}, {'total_brut': '1000.0', 'name': u'AMINE MSAKNI ', 'presence': '0', 'salaire_imposable': '8180.0', 'net_payer': '442.558', 'absence': '0', 'retenue_source': '465.642', 'cnss_sal': '9180.0', 'cnss_pat': '16570.0', 'matricule': '5', 'heures_sup': '0'}, {'total_brut': '1000.0', 'name': u'AYMEN HAMROUNI', 'presence': '0', 'salaire_imposable': '8180.0', 'net_payer': '442.558', 'absence': '0', 'retenue_source': '465.642', 'cnss_sal': '9180.0', 'cnss_pat': '16570.0', 'matricule': '6', 'heures_sup': '0'}, {'total_brut': '1000.0', 'name': u'JINENE HEDFI', 'presence': '0', 'salaire_imposable': '8180.0', 'net_payer': '442.558', 'absence': '0', 'retenue_source': '465.642', 'cnss_sal': '9180.0', 'cnss_pat': '16570.0', 'matricule': '7', 'heures_sup': '0'}, {'total_brut': '1000.0', 'name': u'MOHAMED JRIBI', 'presence': '0', 'salaire_imposable': '8180.0', 'net_payer': '442.558', 'absence': '0', 'retenue_source': '465.642', 'cnss_sal': '9180.0', 'cnss_pat': '16570.0', 'matricule': '3', 'heures_sup': '0'}]

Drees, please change the variable, 'o' with 'p' or something else in :
[[ repeatIn(get_employee_lines(example.company_id,example.date_start,example.date_end, 0, 6), 'o', 'td') ]]
and,
[[ o['name'] ]]
in rml file....

Author

i have changed it but nothing happens

Author

pawan in my list i have 7 employees and i want to display 3 employees per page :/

Drees, Are you using the 'o' from first function ([[ repeatIn(get_employee_taille(example.company_id,example.date_start,example.date_end), 'o') ]]), anywhere in your code??
since i can't see its use anywhere..... and everything else is seeming fine only for the error u said is raising(TypeError: 'int' object is not iterable)

Author

Here is my RML:

[[ repeatIn(get_employee_taille(example.company_id,example.date_start,example.date_end), 'p') ]] NOM EMPLOYÉ [[ repeatIn(get_employee_lines(example.company_id,example.date_start,example.date_end, 0, 6), 'p', 'td') ]] [[ p['name'] ]]
Now i have got this:2015-09-08 11:53:42,969 6510 ERROR openerp openerp.service.web_services: Exception: <LongTable@0x7FDDE6488F38 0 rows x unknown cols>... must have at least a row and column

Author

The problem here is that in repeatIn(get_employee_lines(example.company_id,example.date_start,example.date_end, 0, 6), 'p', 'td') ]] i dont want to pass the start_position and number of columns. its static i want him give me in each page 6 employees :/

In , you have given widths for 5 cols(colwidths="150,100,100,100,100,100"), but inside that

you are having 2 only.
Second , for your error, after second "" tag([[ repeatIn(get_employee_lines(example.company_id,example.date_start,example.date_end, 0, 6), 'o', 'td') ]]) you are not having any which is expected by rml parser.
These are reasons... i think...
Author

So what shall i do please :/ help me pawan

Drees, it would be very nice if i can help you, but we have to go through your code, if u want then you can drop ur skype id at my email, i will contact u there asap. :)

Author

here is my mail pawan : abdelwahed_rihene@yahoo.fr

Author

i want to display x columns per page but i dont know how please try to help me my friend

Author Best Answer

Hello!!!!

Finally i have got the answer :)

Here is the RML code:

<blockTable colwidths="150,100,100,100,100,100" style="Table1">

<tr>

<td>

<para style="P8">NOM EMPLOYÉ</para>

</td>

<td>

<para style="P8">MATRICULE</para>

</td>

<td>

<para style="P7">[[ repeatIn(repeatIn(get_employee_lines(example.company_id,example.date_start,example.date_end), 'p', 'td'),'o') ]]</para>

<para style="P7">[[ repeatIn(o['p'], 'line', 'td') ]]</para>

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

<para style="P7">[[ line['matricule'] ]]</para>

</td>

</tr>

</blockTable>

Best Regards.

Avatar
Discard
Related Posts Replies Views Activity
0
Apr 18
1961
0
Feb 18
2518
1
Sep 15
2771
1
Sep 15
2476
0
Sep 15
2290