It is currently Mon May 21, 2012 6:23 pm

All times are UTC + 2 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: [OK] Problem accessing field data many2one same class object
PostPosted: Wed Apr 27, 2011 12:47 pm 
Offline

Joined: Tue Feb 15, 2011 2:18 pm
Posts: 26
Hello.
I am using a wizard and not how to access data in a field many2one available to the active object. The problem is that if you can not do this kind of query in a wizard, or if you can, as I can pass the field reference for consulting many2one fields available.
The code is as follows:
Code:
def _createName(self, cr, uid, data, context):
    product_obj = pooler.get_pool(cr.dbname).get('product.product')

    for product in product_obj.browse(cr, uid, data['ids'], context=context):
        reads = product_obj.read(cr, uid, [product.id])
        for record in reads:
            name = record['acabado'].name    ##acces field many2one
            code = record['default_code']        ##acces field char

The error I get is:
name = record['acabado'].name
AttributeError: 'tuple' object has no attribute 'name'

Any help?? Thanks!!


Top
 Profile  
 
 Post subject: Re: [OK] Problem accessing field data many2one same class ob
PostPosted: Fri Apr 29, 2011 5:46 pm 
Offline

Joined: Tue Feb 15, 2011 2:18 pm
Posts: 26
Fixed. Finally, the error was that when I go to a tuple of values ​​such as: (1, u'acabado1 ') must specify the tuple containing the desired information using brackets, being as follows:
Code:
acabado = record['acabado'][1]

Hope it helps more people !!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP