Odoo Help

Welcome!

This community 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.

0

'bool' object has no attribute '__getitem__'

By
tf
on 8/29/13, 1:08 PM 8,573 views

Hello, Have someone get this error; 'bool' object has no attribute '__getitem__'

Hello Francesco, when I try this code, Ihave a keyError. Can you help me?

tf
on 9/5/13, 2:59 PM
2

Francesco OpenCode

--Francesco OpenCode--
3608
| 5 7 9
Grottaglie, Italy
--Francesco OpenCode--

Italian Odoo (OpenERP) Modules Developer LINKEDIN: http://www.linkedin.com/in/francescoapruzzese

Francesco OpenCode
On 8/29/13, 1:14 PM

This is a classic error you obtain when are you reference your pool.get to a class that doesn't exist. Read your code and search the error or post the code and we can help you.

EDIT:

Try this code for the function:

def get_convertedamount(self, cr,uid,ids,field_name,arg,context=None):
     res={}
     for pchange in self..browse(cr,uid,ids):
         res[pchange.id].update({'convertedamount' : pchange.conversionrate * pchange[.amountbeconverted})
     return res

Hello Francesco, thank you for your answer

this is my code:

class changemanual_change(osv.osv):

def get_convertedamount(self, cr,uid,ids,field_name,arg,context=None):
       res={}
     if context is None:
         context = {}
     pchange = self.pool.get('changemanual.change').browse(cr,uid,id,)

    res['convertedamount']=pchange['conversionrate']*pchange['amountbeconverted']        
     return res

_name = 'changemanual.change'    
_columns = {
    'partner_id': fields.many2one('res.partner','Customer'),
    'currency_id'
tf
on 8/29/13, 1:22 PM

In this line pchange = self.pool.get('changemanual.change').browse(cr,uid,id,) you call "id" but id is not defined.

Francesco OpenCode
on 8/29/13, 2:17 PM
1
mike
On 8/29/13, 2:20 PM

Browse objects employ object notation to access attributes. Try

pchange.conversionrate*pchange.amountbeconverted

Also I advise conditional test for existence of value.

if pchange.conversionrate and pchange.amountbeconverted:
    res['convertedamount'] = pchange.conversionrate*pchange.amountbeconverted

Otherwise you have typeerror when ORM returns False.

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 8/29/13, 1:08 PM
Seen: 8573 times
Last updated: 3/16/15, 8:10 AM