Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
8930 Lượt xem

Hello,

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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 

  https://github.com/Leningsv/Odoo/wiki/Valores-por-Defecto

https://github.com/Leningsv/Odoo/wiki/Valores-por-Defecto 

https://github.com/Leningsv/Odoo/wiki/Valores-por-Defecto   

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'''          
@api.model
def default_get(self, vals):
    auxOrganizerType= self.env['gol.organizer.type'].search([])
    listItemOrganizerAccount=[]
    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'''
        listItemOrganizerAccount.append((0,0,{'auxType':item.id}))
    res = super(GolAccount, self).default_get(vals)      
    res.update({'itemOrganizerAccount': listItemOrganizerAccount})
    return res
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi.

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

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


Good luck !!

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 12 22
4278
1
thg 3 23
2336
0
thg 12 22
2979
0
thg 6 21
2906
0
thg 6 20
5418