Quantcast
Viewing all articles
Browse latest Browse all 39

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

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) newcte=test_name.numcte 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'), } res_partner() 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.

Viewing all articles
Browse latest Browse all 39

Trending Articles