Odoo Help

Welcome!

This community 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.

0

TypeError: 'int' object is not iterable RML

By
Drees Far
on 9/8/15, 5:57 AM 876 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

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

Pawan
on 9/8/15, 7:02 AM

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

Drees Far
on 9/8/15, 7:03 AM

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

Drees Far
on 9/8/15, 7:06 AM

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 :/

Drees Far
on 9/8/15, 7:15 AM

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

Pawan
on 9/8/15, 7:20 AM

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 Far
on 9/8/15, 7:25 AM

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....

Pawan
on 9/8/15, 7:38 AM

i have changed it but nothing happens

Drees Far
on 9/8/15, 7:43 AM

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

Drees Far
on 9/8/15, 7:43 AM

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)

Pawan
on 9/8/15, 7:50 AM

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

Drees Far
on 9/8/15, 7:56 AM

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 :/

Drees Far
on 9/8/15, 7:58 AM

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...

Pawan
on 9/8/15, 8:18 AM

So what shall i do please :/ help me pawan

Drees Far
on 9/8/15, 8:23 AM

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. :)

Pawan
on 9/8/15, 8:28 AM

here is my mail pawan : abdelwahed_rihene@yahoo.fr

Drees Far
on 9/8/15, 8:31 AM

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

Drees Far
on 9/8/15, 8:35 AM
0

Drees Far

--Drees Far--
1130
| 5 2 6
Tunis, Tunisia
--Drees Far--
Drees Far
On 9/9/15, 9:10 AM

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 9/8/15, 5:57 AM
Seen: 876 times
Last updated: 9/9/15, 9:11 AM