Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
7678 Vues

Hello,

I'm using the latest OpenERP 7 version download from the site. I have a module overriden hr.employee just adding some fields. I loaded the data from the old systeem via the import functionality into OpenERP. Now I want to update the custom module by launching OpenERP via the argument --update=<my module="">. I get the following error:

WARNING: No field_values found for ids [43] in browse_record(hr.employee, 43) ERROR: Field resource_id not found in browse_record(hr.employee, 43)

The stacktrace is as follows:

> Traceback (most recent call last):  
> File "/home/fsan/Projects/OpenERP
> 7.0/openerp/netsvc.py", line 292, in dispatch_rpc
>     result = ExportService.getService(service_name).dispatch(method,
> params)   File
> "/home/fsan/Projects/OpenERP
> 7.0/openerp/service/web_services.py", line 622, in dispatch
>     security.check(db,uid,passwd)   File

"/home/fsan/Projects/OpenERP

7.0/openerp/service/security.py", line 40, in check pool = pooler.get_pool(db) File "/home/fsan/Projects/OpenERP 7.0/openerp/pooler.py", line 49, in get_pool return get_db_and_pool(db_name, force_demo, status, update_module)[1] File "/home/fsan/Projects/OpenERP 7.0/openerp/pooler.py", line 33, in get_db_and_pool registry = RegistryManager.get(db_name, force_demo, status, update_module)
File "/home/fsan/Projects/OpenERP 7.0/openerp/modules/registry.py", line 192, in get update_module) File "/home/fsan/Projects/OpenERP 7.0/openerp/modules/registry.py", line 218, in new openerp.modules.load_modules(registry.db, force_demo, status, update_module)
File "/home/fsan/Projects/OpenERP 7.0/openerp/modules/loading.py", line 379, in load_modules pool.get('ir.model.data')._process_end(cr, SUPERUSER_ID, processed_modules)
File "/home/fsan/Projects/OpenERP 7.0/openerp/addons/base/ir/ir_model.py", line 1121, in _process_end self.pool.get(model).unlink(cr, uid, [res_id]) File "/home/fsan/Projects/OpenERP 7.0/openerp/addons/hr/hr.py", line 230, in unlink resource_ids.append(employee.resource_id.id) File "/home/fsan/Projects/OpenERP 7.0/openerp/osv/orm.py", line 488, in __getattr__ raise AttributeError(e) AttributeError: 'Field resource_id not found in browse_record(hr.employee, 43)'

I noticed in the hr.employee code that the unlink method doesn't actually unlink the employee but only the resource attached to the employee although the resource_id field on the hr.employee class is set with "on_delete='cascade'". The super unlink is not called as well. Is this a bug or am I missing something.

BR, volvin

Avatar
Ignorer

I have same issue . Did you find any solution yet? Please help

Meilleure réponse

Hi

hr.employee and resource.resource are two different objects/table, but are bounded together in hr.employee using inherits property.. so for every record in hr.employee there should exists a corresponding record in resource.resource, (resulting otherwise will throw such error)..

thus make sure, both tables are imported accordingly...

Avatar
Ignorer

Thanks deep. this is my code ids = args['creditnote_no'] values = {'status':'approved'} employee = self.pool.get('hr.employee').browse(cr, uid, uid, context=context) args['manager_id'] = employee.parent_id.user_id.id Can you please describe what you mean by importing both? where i have to do that?

Hi @deep one more thing if i login as admin i can access the table, but not for other users. Do you have any idea , what the issue is?

For Other user login, make sure you have set access rights for those objects... Check Security Record Rules/ Access Control List

I wonder, why have you assigned ids = args['credit_no'] ? and at the same time you have used UID as ID to browse hr.employee... I think you got confused and entirely passing wrong ids to retrieve the records.....

I guess you are trying to browse the Employee Records for the User who has logged in... If that is the case then try this code... resource_id = self.pool.get('resource.resource').search(cr, uid, [('user_id','=', uid)][0] Emp_id = self.pool.get('hr.employee').search(cr, uid, [('resource_id','=', resource_id)][0]

And then user Emp_id to browse in employee objects.... Employee = self.pool.get('hr.employee').browse(cr, uid, Emp_id)

Hi deep, I tried with that my code is employee = self.pool.get('hr.employee').browse(cr, uid, emp_id) _logger.error("employee.parent_id") _logger.error(employee.parent_id.work_email) but it returns none for email id.. Can you please help

Hi deep, I tried with that my code is employee = self.pool.get('hr.employee').browse(cr, uid, emp_id) _logger.error("employee.parent_id") _logger.error(employee.parent_id.work_email) but it returns none for email id.. Can you please help

Hi Deep. Thanks alot .. changing the code to resource_id = self.pool.get('resource.resource').search(cr, uid, [('user_id','=', uid)][0] Emp_id = self.pool.get('hr.employee').search(cr, uid, [('resource_id','=', resource_id)][0] corrected my issue.. once more thak you so much Anu