Odoo Help


How to use ORM methods, to get the required data ?

on 7/9/13, 5:19 PM 1,362 views

I need to get the value of field in a tree view of the fields_view_get method and a I use ORM methods to achieve this. my code :

class res_partner(osv.osv):

_inherit = 'res.partner'

def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):

    if context is None:
        context = {}

    partner_obj = self.pool.get('res.partner')
    ids_partner = partner_obj.search(cr, uid, [], context=context)              
    element = partner_obj.browse(cr,uid,ids_partner[0]).numcte

    res = super(res_partner,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)


    doc = etree.XML(res['arch'])

    if view_type == 'tree':

        for node in doc.xpath("//field[@name='numcte']"):
               node.set('string', 'numcte')
        for node in doc.xpath("//button[@name='icono']"):
               node.set('icon', newcte) 

    res['arch'] = etree.tostring(doc)
    return res

_columns = {
    'numcte': fields.text('numero cliente'),


My problem is when I, use for instance :

 element = partner_obj.browse(cr,uid,ids_partner[0]).numcte

It returns me the value of the field that I want, but in the treeView is the same for each row, like this A001, A001, A001, in instead of A001, A002, A003.

in this case ids_partner[0], How can I make this number to be dynamic and changing for each row ?

Or in the case that use this:

 my_data  = partner_obj.read(cr, uid, ids_partner, ["numcte"], context=context)

returns me the tuple like this:

[{'numcte': u'A001', 'id': 3}, {'numcte': u'A002', 'id': 2}, {'numcte': u'A003', 'id': 4}] [{'numcte': u'A001', 'id': 3}, {'numcte': u'A002', 'id': 2}, {'numcte': u'A003', 'id': 4}] [{'numcte': u'A001', 'id': 3}, {'numcte': u'A002', 'id': 2}, {'numcte': u'A003', 'id': 4}]

one for each row

How can I get the value of the field that I want for the correct row. ?

thank you all for your time, I been a while in this so any help is usefull.

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

0 follower(s)


Asked: 7/9/13, 5:19 PM
Seen: 1362 times
Last updated: 3/16/15, 8:10 AM