Odoo Help


ODOO9: How to parse json field in qweb?

Drees Far
on 6/10/16, 4:28 AM 688 views

Hello everybody!!!

Can anyone help me know how to parse a json field in qweb report for odoo9.

Here is my json:

{"employee": [{"id":1,"name":"RIHENE,ABDELWWAHED","matricule":"123456789","worked_day":22,"leave_days":0,"abs_day":0,"worked_holiday":0,"over_25":0,"over_50":0,"over_75":0,"over_100":0,"heures_sup":0,"net_target":0,"wage":"2500.000","contract": {"wage":2500,"adjustment_prime":11399,"struct_id":4,"struct_code":"MENSUEL"},"net":0,"cnss":0,"irpp":0,"brut":0,"base_cnss":0,"cnss_pat":0,"sal_imp":0,"at":0,"total_primes":0,"data_changed":false,"checked":false,"primes_details":false,"hours": [{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0}, {"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0}],"struct":"MENSUEL"}]}

Thanks a lot in advance.

Best regards!

define a method in model and call it over report , and use two for each loop just like pattern printing

webkul, Prakash Sharma
on 6/10/16, 1:06 PM
Arsenty Karamurza
On 6/17/16, 7:52 AM

Don't forget you're inside a browser, so that there's JavaScript at your disposal )



| 4 4 5
Hyderabad, India

On 6/13/16, 9:20 AM


if you are having this in a variable and passed to xml from controller as:

result ={"employee": [{"id":1,"name":"RIHENE,ABDELWWAHED","matricule":"123456789","worked_day":22,"leave_days":0,"abs_day":0,





"hours": [{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0}, {"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0},{"hours":0}],"struct":"MENSUEL"}]}

then you can simply loop through it  and traverse over the data as:

<t t-foreach="employee" t-as="emp">

here 'emp' will singify each employee, and you can you normal python dictionary convention here:

emp['id'], will give you 1,

emp['name'] will give you 'RIHENE,ABDELWWAHED', and so on.......

and further again you can loop through each hours as,

<t t-foreach="emp['hours']" t-as="hour">

Then get each hour in loop........

Hope this will help you....

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


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/10/16, 4:28 AM
Seen: 688 times
Last updated: 6/17/16, 7:52 AM