This question has been flagged
3 Replies
19739 Views

Hello All,

I getting this error while applying function in Odoov10.

TypeError: unsupported operand type(s) for +: 'bool' and 'str'.

**My Python code is here:**


    @api.multi

        def name_get(self):

            result = []

            print "re:", result

            for record in self:

                print "R:", record

                name = '[' + record.pet_name + ']' + ' ' + record.name

                result.append((record.id, name))

            return result

Avatar
Discard

here the type of the record will be of unicode, change it to str and do the operation

Author

Hello Niyas,

I getting wrong value for this fucntion instead of 'pet_name' i getting 'patner_id(customer name)'. Can you provide me exact solution for this problem?

Author

Hello NIyas,

Now, My function work well. But, Can u tell me how to call this function for particular class only, not global. My class name is "body_processing" where i want to call this 'name_get' function. My code is here:

@api.multi

def name_get(self):

result = []

for record in self:

name = '['

if record.pet_name:

name += record.pet_name + ']' + ' ' + record.name

else:

name += '] ' + record.name

result.append((record.id, name))

return result

Best Answer

Pawan, 

try applying the quotes around record.name

name = '[' + record.pet_name + ']' + ' ' + 'record.name'

and try.

Avatar
Discard