1
votes

I want to print employee details from hr.employee model to my qweb report(Purchase Requisition).

I am trying the code like following:

                            <tr>
                                <td style="border:1px solid #000;padding-left:5px">Department:<span t-esc="o.user_id.partner_id.department_id.name"/></td>
                                <td style="border:1px solid #000;padding-left:5px"> </td></tr>

And facing this error: Error to render compiling AST AttributeError: 'res.partner' object has no attribute 'department_id'

I understood that my current object does'nt contain department_id field. Then how can I get this employee details from hr.employee model for the logged in user??

Any help is highly appreciated and I am using odoo 10. Thanks!

2
Just check the existing modules in odoo apps - Navi

2 Answers

0
votes

I end up with the following solution which worked for me.

For relational fields use @Yajo solution:

<span t-esc="','.join(o.user_id.mapped('employee_ids.department_id.display_name'))" />

For other fields use this:

<span t-esc="request.env.user.employee_ids.mobile_phone" />

Thanks for your kind replies!

0
votes

According to the code of the hr module, you most likely need to use:

<span t-esc="', '.join(o.user_id.mapped('employee_ids.department_id.display_name'))"/>