Odoo Help


Return value in field function openerp v7

lam a bao
on 11/28/13, 10:35 PM 3,049 views

Hi erveryone: I have function :

  def getcodesystemdoor(self, cr, uid, ids,fields, arg, context=None):

         getids= self.read(cr,uid,ids,['demomany2one'])[0]['demomany2one']
         search_oj=get_oj.search(cr, uid, [('id', '=',getids[0])])
       data_oj=get_oj.read(cr, uid, search_oj, ['id','parent_id'], context)
       for item in data_oj:
       return x

and columns:

"codesystemdoor":fields.function(getcodesystemdoor,method = True, String='Sum cost',type="integer")

when I excute , error 'list' object has no attribute 'get'

can you help me ?

I think your search_oj is a list. Try using it like: search_oj[0] or add: limit=1 to search methods arguments when initializing it.

Jaakko Komulainen
on 11/29/13, 2:41 AM
Julio Serna
On 11/29/13, 8:46 PM

If "demomany2one" field is of type "many2one" you can try this:

def getcodesystemdoor(self, cr, uid, ids,fields, arg, context=None):
        for item in self.browse(cr, uid, ids, context=context):
            search_oj=get_oj.search(cr, uid, [('id', '=', item.demomany2one.id)])
            data_oj=get_oj.browse(cr, uid, search_oj, context=context)[0]
        return x

best regards

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

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: 11/28/13, 10:35 PM
Seen: 3049 times
Last updated: 3/16/15, 8:10 AM