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

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

By
Pablo Manuel Rizzo
on 10/30/13, 4:14 AM 7,607 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?

1

Acespritech

--Acespritech--
839
| 3 2 6
India
--Acespritech--

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

Acespritech
On 10/30/13, 6:00 AM

Hello,

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

Thanks,
www.acespritech.com

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

Pablo Manuel Rizzo
on 10/30/13, 8:24 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: 10/30/13, 4:14 AM
Seen: 7607 times
Last updated: 3/16/15, 8:10 AM