Odoo Help


How to show a column on tree

Javier Batres Velásquez
on 1/22/15, 10:10 AM 1,190 views

Hello I am trying to show a field of my foreign key on my tree. for example

<tree string="Course Tree">

          <field name="responsible_id.partner_nit"/> <!-- This is the field that I want to show. -->


Note: this is inside a record where the model is "session" but "responsuble_id" is a Many2one relationship whit "res.partner"

I can't find a form for this. Thank yout for all the help


Hello i have solved that reading more crefully the ORM Documentation.

In the paste the fields.realted() was sucessfull, but now on the version 8, the sintaxis is:

nit = field.<Type of data>(related="field on model.information", store=False)

I wait that this be usefull for someone more.


Thanks for all the help



On 1/26/15, 10:03 AM

Hello javier,

As long as I know, this not possible to display a field from another model using the Many2One directly.

Also, you can create a related field in your model, which will automatically retrieve the value of partner_nit. For example: 

'responsible_partner_nit': fields.related('responsible_id', 'partner_nit', 'Partner NIT')

And you display this new field in your tree view.


Notes: If you want to filter your list with this new field (sorting or filtering the list), you have to add a store parameter to your field definition (in Python model) so that Odoo will store the value in DB, re-compute it only when needed, and wil be able fo filter on this field: 

def _get_session_from_partner(self, cr, uid, ids, context=None) {

    return self.pool.get('your.model.session').search(cr, uid, [('responsible_id.id', 'in', ids')], context=context)


_columns = {


'    responsible_partner_nit': fields.related('responsible_id', 'partner_nit', 'Partner NIT',

            store={'your.model.session': lambda *a: self, cr, uid, ids, ctx: ids, ['responsible_id'], 10],

                'res.partner':[_get_session_from_partner, ['partner_nit'], 11})


Hope it helps you,


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: 1/22/15, 10:10 AM
Seen: 1190 times
Last updated: 3/16/15, 8:10 AM