Odoo Help

0

0
2 回答
1

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

 

 

1
Bruno PLANCHER フランス
2015/01/26 10:03

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,

Regards

質問する
Keep Informed
1 フォロワー
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.

Register
Odoo Training Center

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

Test it now