تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
22056 أدوات العرض

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

الصورة الرمزية
إهمال

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

الكاتب

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?

الكاتب

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

أفضل إجابة

Pawan, 

try applying the quotes around record.name

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

and try.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
فبراير 18
12062
0
سبتمبر 17
3491
0
أكتوبر 19
3404
5
سبتمبر 19
11906
0
أكتوبر 17
5268