Odoo Help


_rec_name and name_get

Dércio Duvane
on 9/2/14, 12:03 PM 3,610 views

Hello, I am having some problems with some orm methods, i.e, copy and read.

Following the error description I tried to fix it but still nothing. Below there's a traceback of it.


Traceback (most recent call last):

  File "/opt/dotcomerp/server/openerp/osv/osv.py", line 121, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/opt/dotcomerp/server/openerp/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/opt/dotcomerp/server/openerp/osv/osv.py", line 164, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/opt/dotcomerp/server/openerp/addons/dotcom_doc_rendas/inherits.py", line 101, in copy
    return super(dotcom_venda, self).copy(cr, uid, id, default=default, context=context)
  File "/opt/dotcomerp/server/openerp/addons/dotcom_cm_conversion/inherits.py", line 124, in copy
    return super(dotcom_venda, self).copy(cr, uid, id, default=default, context=context)
  File "/opt/dotcomerp/server/openerp/addons/dotcom_stock/stock.py", line 360, in copy
    return super(dotcom_venda, self).copy(cr, uid, id, default=default, context=context)
  File "/opt/dotcomerp/server/openerp/addons/dotcom_doc/sales/dotcom_venda.py", line 705, in copy
    return osv.osv.copy(self, cr, uid, id, default=default, context=context)
  File "/opt/dotcomerp/server/openerp/osv/orm.py", line 4731, in copy
    data = self.copy_data(cr, uid, id, default, context)
  File "/opt/dotcomerp/server/openerp/osv/orm.py", line 4611, in copy_data
    data = self.read(cr, uid, [id,], context=context_wo_lang)
  File "/opt/dotcomerp/server/openerp/osv/orm.py", line 3381, in read
    result = self._read_flat(cr, user, select, fields, context, load)
  File "/opt/dotcomerp/server/openerp/osv/orm.py", line 3504, in _read_flat
    res2 = self._columns[f].get(cr, self, ids, f, user, context=context, values=res)
  File "/opt/dotcomerp/server/openerp/osv/fields.py", line 488, in get
  File "/opt/dotcomerp/server/openerp/osv/orm.py", line 2258, in name_get
    [self._rec_name], context, load='_classic_write')]
KeyError: 'name'



As an effort to fix it I tried to create a name_get method then a _rec_name declaration but still nothing.


Any Ideas?

Py file download link below:


Please attach your code of dotcom_venda.py

GH Mediacloud, Grover Menacho
on 9/2/14, 2:55 PM
Marvin Taboada
On 9/2/14, 4:27 PM

Hello Dércio,

Overriding `name_get` is not necessary. If you don't declare any field with 'name' as its technical name, you should define `_rec_name` with the name of a column that appropriately identifies every record but is not necessarily unique. See the 'hr_evaluation.evaluation' object in the 'hr_evaluation' module as an example, and also see https://doc.openerp.com/trunk/server/03_module_dev_02/

OpenERP expects that all objects define (implicitly or explicitly) a column that is used as a "display name" for the object. This "display name" is used by default in several places, at searches (without specifying explicit filters for the search), at populating combo-boxes in relational fields, in the Audit Trail module to appropriately identify resources, etc.

The version you're using (6.1) attempts to access a 'name' key in the dictionary of results just after a `read`, that's why KeyError arises.

Thanks for your reply Marvin. I've tried all those ways before. Yet still not working!

Dércio Duvane
on 9/3/14, 4:26 AM
Dércio Duvane
On 9/3/14, 4:25 AM

Hello, guys as requested here's the link for the header of the py file. I didn't include the remaining methods because are working fine. 








| 5 3 6
Jakarta, Indonesia
On 9/3/14, 4:49 AM

I think it has something to do with the fact that 'name_parsed' field that you are using for _rec_name is a function field that is not stored.  AFAIK field used in _rec_name need to be physically existing in database (i.e. stored).

Still no good! I have stored it and nothing, plus the _rec_name declaration is commented so it should use the name_get method

Dércio Duvane
on 9/3/14, 5:02 AM

Dércio Duvane, Odoo/OpenERP ORM must have a field that is designated to be the 'name' of the object model. By default it is either a field named 'name' or specified in _rec_name declaration. So, since the dotcom.venda object does not have a field named 'name', then you should uncomment the _rec_name declaration.

on 9/3/14, 5:40 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

2 follower(s)


Asked: 9/2/14, 12:03 PM
Seen: 3610 times
Last updated: 3/16/15, 8:10 AM