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

TypeError: cannot concatenate 'str' and 'instancemethod' objects

By
PY
on 9/19/14, 6:35 AM 2,462 views

Hi !

I have a weird issue there. Here's my code :

class xml_request(osv.osv):
    _name = 'xml.request'
    _columns = {
        'config_id': fields.many2one('synconfig', 'Config id'),
        # [...]
    }
    def name_get(self, cr, uid, ids, context=None):
        res = []
        for rec in self.browse(cr, uid, ids, context=context):
            conf = rec.config_id
            # [...]
        return res

Here's the error:

Traceback (most recent call last):
    File "/home/openerp/server/openerp/netsvc.py", line 297, in dispatch_rpc
        result = ExportService.getService(service_name).dispatch(method, params)
    File "/home/openerp/server/openerp/service/web_services.py", line 626, in dispatch
        res = fn(db, uid, *params)
    File "/home/openerp/server/openerp/osv/osv.py", line 190, in execute_kw
        return self.execute(db, uid, obj, method, *args, **kw or {})
    File "/home/openerp/server/openerp/osv/osv.py", line 132, in wrapper
        return f(self, dbname, *args, **kwargs)
    File "/home/openerp/server/openerp/osv/osv.py", line 199, in execute
        res = self.execute_cr(cr, uid, obj, method, *args, **kw)
    File "/home/openerp/server/openerp/osv/osv.py", line 187, in execute_cr
        return getattr(object, method)(cr, uid, *args, **kw)
    File "/home/openerp/server/openerp/osv/orm.py", line 3679, in read
        result = self._read_flat(cr, user, select, fields, context, load)
    File "/home/openerp/server/openerp/osv/orm.py", line 3800, in _read_flat
        res2 = self._columns[f].get(cr, self, ids, f, user, context=context, values=res)
    File "/home/openerp/server/openerp/osv/fields.py", line 468, in get
        context=context))
    File "/home/openerp/custom_addons/synconfig/xml_request/xml_request.py", line 71, in name_get
        conf = rec['config_id']
    File "/home/openerp/server/openerp/osv/orm.py", line 405, in __getitem__
        field_values = self._table.read(self._cr, self._uid, ids, field_names, context=self._context, load="_classic_write")
    File "/home/openerp/server/openerp/osv/orm.py", line 3679, in read
        result = self._read_flat(cr, user, select, fields, context, load)
    File "/home/openerp/server/openerp/osv/orm.py", line 3729, in _read_flat
        query += " ORDER BY " + order_by
TypeError: cannot concatenate 'str' and 'instancemethod' objects

EDIT:

Today, monday, I've not changed anything, but the error has changed ! :O Here's the traceback:

Traceback (most recent call last): 
    File "/home/openerp/server/openerp/netsvc.py", line 297, in dispatch_rpc 
        result = ExportService.getService(service_name).dispatch(method, params) 
    File "/home/openerp/server/openerp/service/web_services.py", line 626, in dispatch 
        res = fn(db, uid, *params) 
    File "/home/openerp/server/openerp/osv/osv.py", line 190, in execute_kw 
        return self.execute(db, uid, obj, method, *args, **kw or {}) 
    File "/home/openerp/server/openerp/osv/osv.py", line 132, in wrapper 
        return f(self, dbname, *args, **kwargs) 
    File "/home/openerp/server/openerp/osv/osv.py", line 199, in execute 
        res = self.execute_cr(cr, uid, obj, method, *args, **kw) 
    File "/home/openerp/server/openerp/osv/osv.py", line 187, in execute_cr 
        return getattr(object, method)(cr, uid, *args, **kw) 
    File "/home/openerp/server/openerp/osv/orm.py", line 2372, in search 
        return self._search(cr, user, args, offset=offset, limit=limit, order=order, context=context, count=count) 
    File "/home/openerp/server/openerp/osv/orm.py", line 4937, in _search 
        order_by = self._generate_order_by(order, query) 
    File "/home/openerp/server/openerp/osv/orm.py", line 4879, in _generate_order_by 
        self._check_qorder(order_spec) 
    File "/home/openerp/server/openerp/osv/orm.py", line 4771, in _check_qorder 
        if not regex_order.match(word):
TypeError: expected string or buffer

 

EDIT:

Tried upgrading openerp to latest version (still v7), tried with another new database, but I still get this error.

Omg what's wrong with code formating :O

PY
on 9/22/14, 3:30 AM
0
PY
On 9/22/14, 5:11 AM

OK, so, after going deep in the server files, after several "print this" and "print type(that)", I finally figured out what was wrong.

In fact, I had a function named "_order" in my object "xml.request". Renaming it, problem solved.

(Didn't realised that my "_order" function was overriding the "_order" member of osv.osv -_- )

0
Artur Bertram
On 9/19/14, 10:58 AM

The problem originates form this row.

conf = rec.config_id

You need to add the field you want to show or otherwise its just the browse_record() method from the "synconfig" class you are saving in conf.

I know, in fact I'm using this browse record to find other browse records, fields and so on, in order to build the name I want this function to return. By question was about to solve, or at least find out why this problem occured there ? I've used browse records many times before, and I've never seen this error on these objects...

PY
on 9/22/14, 3:10 AM

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

1 follower(s)

Stats

Asked: 9/19/14, 6:35 AM
Seen: 2462 times
Last updated: 3/16/15, 8:10 AM