Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
12608 Visualizzazioni

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.

[code]

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
    context=context))
  File "/opt/dotcomerp/server/openerp/osv/orm.py", line 2258, in name_get
    [self._rec_name], context, load='_classic_write')]
KeyError: 'name'

[code]

 

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:

http://bit.ly/1lHmAvE

Avatar
Abbandona

Please attach your code of dotcom_venda.py

Risposta migliore

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.

Avatar
Abbandona
Autore

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

Autore Risposta migliore

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. 

http://bit.ly/1lHmAvE

 

 

 

Avatar
Abbandona
Risposta migliore

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).

Avatar
Abbandona
Autore

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, 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.

Post correlati Risposte Visualizzazioni Attività
2
gen 18
22494
0
mar 15
7301
1
apr 23
4130
1
gen 24
8523
2
apr 15
20779