Odoo Help


Failed to initialize database. KeyError: 'hr.expense.expense' when adding a one2many

Aitor Bouzas
on 4/29/15, 3:29 AM 2,351 views


I have this code:

from openerp.osv import fields, osv
from openerp.tools.translate import _
import openerp
class hr_expense_expense(osv.osv): _inherit = 'hr.expense.expense' _columns = { 'issue_id': fields.many2one('account.analytic.line','Incidencia'), }
class account_analytic_line(osv.osv): _description = 'Analytic Line' _inherit = 'account.analytic.line' _columns = { 'expenses_id': fields.one2many('hr.expense.expense','issue_id','Gastos'), }

And get this error:

2015-04-29 07:13:55,604 4039 CRITICAL Conecta openerp.service.server: Failed to initialize database `Conecta`.
Traceback (most recent call last):
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/service/server.py", line 906, in preload_registries
registry = RegistryManager.new(dbname, update_module=update_module)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/registry.py", line 341, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/loading.py", line 354, in load_modules
force, status, report, loaded_modules, update_module)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/loading.py", line 263, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/loading.py", line 158, in load_module_graph
models = registry.load(cr, package)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/registry.py", line 148, in load
model = cls._build_model(self, cr)
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/models.py", line 595, in _build_model
original_module = pool[name]._original_module if name in parents else cls._module
File "/opt/bitnami/apps/odoo/lib/odoo-8.0_a2115ef-py2.7.egg/openerp/modules/registry.py", line 101, in __getitem__
return self.models[model_name]
KeyError: 'hr.expense.expense'

I'm just trying to add a relation between expense and timesheet, so the user can add it's expenses in the timesheet (and keep related the work he did, with its expenses)

Hope you can help me. Thank you.

On 3/7/16, 12:25 PM

Hola como estas Tengo la solucion Mira este ejemplo

Si quieres saber como lo hise entra a mi pagina ahi describo paso a paso su elaboracion. Y proximamente hare videos por el momonto solo ingresa ami pagina https://github.com/Leningsv/Odoo/wiki/Valores-por-Defecto  tienes que dirigirte al tema 




Valores por defecto One2Many

'''Con esta Funcion pongo valores por defecto el las cuentas de tipo ordenador
Esto lo hago con la finalidad que esten listadas todas las cuentas tipo ordenador'''          
def default_get(self, vals):
    auxOrganizerType= self.env['gol.organizer.type'].search([])
    for item in auxOrganizerType:
        '''Aqui lleno mi lista con un array para esto adjunte () diciendole a mi lista que lo que
        ingreso es un array'''
    res = super(GolAccount, self).default_get(vals)      
    res.update({'itemOrganizerAccount': listItemOrganizerAccount})
    return res
Jose M. González
On 12/16/15, 1:21 PM


I had the same problem and you only need to add in __openerp.py__ this line:  

'depends': ['base', 'hr', 'hr_expense']

Good luck !!

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: 4/29/15, 3:29 AM
Seen: 2351 times
Last updated: 3/7/16, 12:25 PM