Odoo Help


Error AttributeError: 'str' object has no attribute 'get'

Pablo Manuel Rizzo
on 10/30/13, 4:14 AM 10,883 views

We have an error here:

class account_invoice(osv.osv):

_inherit = 'account.invoice'

def _number(self, cr, uid, ids, name, args, context=None):
    result = {}
    for invoice in self.browse(cr, uid, ids, args):
        result[invoice.id] = invoice.invoice_number
    return result    

_columns = {
    'invoice_number': fields.char('Numero de Factura', size=32, help="El numero de factura es unico"),
    'number': fields.function( _number, 'Numero', type='char', size=32, store=True, method=True),
Server Traceback (most recent call last):
  File "/home/openerp/src/v70/web/addons/web/session.py", line 89, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/home/openerp/src/v70/server/openerp/netsvc.py", line 292, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/openerp/src/v70/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/home/openerp/src/v70/server/openerp/osv/osv.py", line 188, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/home/openerp/src/v70/server/openerp/osv/osv.py", line 131, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/openerp/src/v70/server/openerp/osv/osv.py", line 197, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/openerp/src/v70/addons/audittrail/audittrail.py", line 514, in execute_cr
    return fct_src(cr, uid, model, method, *args, **kw)
  File "/home/openerp/src/v70/server/openerp/osv/osv.py", line 185, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/openerp/src/v70/addons/mail/mail_thread.py", line 242, in create
    thread_id = super(mail_thread, self).create(cr, uid, values, context=context)
  File "/home/openerp/src/v70/server/openerp/osv/orm.py", line 4480, in create
    self.pool.get(object)._store_set_values(cr, user, ids, fields2, context)
  File "/home/openerp/src/v70/server/openerp/osv/orm.py", line 4629, in _store_set_values
    result = self._columns[f].get(cr, self, ids, f, SUPERUSER_ID, context=context)
  File "/home/openerp/src/v70/server/openerp/osv/fields.py", line 1133, in get
    result = self._fnct(obj, cr, uid, ids, name, self._arg, context)
  File "/home/openerp/src/v70/addons-local/7.0/retention_sequence/invoice.py", line 35, in _number
    result[invoice.id] = invoice.invoice_number
  File "/home/openerp/src/v70/server/openerp/osv/orm.py", line 486, in __getattr__
    return self[name]
  File "/home/openerp/src/v70/server/openerp/osv/orm.py", line 401, in __getitem__
    field_values = self._table.read(self._cr, self._uid, ids, field_names, context=self._context, load="_classic_write")
  File "/home/openerp/src/v70/server/openerp/osv/orm.py", line 3606, in read
    result = self._read_flat(cr, user, select, fields, context, load)
  File "/home/openerp/src/v70/server/openerp/osv/orm.py", line 3666, in _read_flat
    if context.get('lang'):
AttributeError: 'str' object has no attribute 'get'

What could be the problem?




| 3 2 6
Gandhinagar, India

Having 8+ years of OpenERP Experience. We are Specialized in OpenERP/CRM Solutions, software development, Web development, E commerce solutions & other open source solutions.

Skype : acespritech

Email : info@acespritech.com

On 10/30/13, 6:00 AM


Use the following method:

def _number(self, cr, uid, ids, name, args, context=None):
    result = {}
    for invoice in self.browse(cr, uid, ids):
        result[invoice.id] = invoice.invoice_number
    return result


That fixed it, thanks! Can you explain the reason?

Naltu, Pablo Manuel Rizzo
on 10/30/13, 8:24 AM

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

1 follower(s)


Asked: 10/30/13, 4:14 AM
Seen: 10883 times
Last updated: 3/16/15, 8:10 AM