This question has been flagged
11 Replies
8558 Views

Hi,

I've this error when I try to install a module in openerp 6.1 ProgrammingError: there is no primary key for referenced table "res_users"

Client Traceback (most recent call last):
  File "/home/irachid/Bureau/server/openerp/addons/web/common/http.py", line 180, in dispatch
    response["result"] = method(controller, self, **self.params)
  File "/home/irachid/Bureau/server/openerp/addons/web/controllers/main.py", line 1052, in call_button
    action = self.call_common(req, model, method, args, domain_id, context_id)
  File "/home/irachid/Bureau/server/openerp/addons/web/controllers/main.py", line 996, in call_common
    return self._call_kw(req, model, method, args, {})
  File "/home/irachid/Bureau/server/openerp/addons/web/controllers/main.py", line 1010, in _call_kw
    return getattr(req.session.model(model), method)(*args, **kwargs)
  File "/home/irachid/Bureau/server/openerp/addons/web/common/openerplib/main.py", line 250, in proxy
    args, kw)
  File "/home/irachid/Bureau/server/openerp/addons/web/common/openerplib/main.py", line 117, in proxy
    result = self.connector.send(self.service_name, method, *args)
  File "/home/irachid/Bureau/server/openerp/addons/web/common/http.py", line 608, in send
    raise xmlrpclib.Fault(openerp.tools.exception_to_unicode(e), formatted_info)


Server Traceback (most recent call last):
  File "/home/irachid/Bureau/server/openerp/addons/web/common/http.py", line 593, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/home/irachid/Bureau/server/openerp/netsvc.py", line 360, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/irachid/Bureau/server/openerp/service/web_services.py", line 586, in dispatch
    res = fn(db, uid, *params)
  File "/home/irachid/Bureau/server/openerp/osv/osv.py", line 167, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/home/irachid/Bureau/server/openerp/osv/osv.py", line 121, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/home/irachid/Bureau/server/openerp/osv/osv.py", line 176, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/home/irachid/Bureau/server/openerp/osv/osv.py", line 164, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/home/irachid/Bureau/server/openerp/addons/base/module/module.py", line 361, in button_immediate_install
    db, pool = pooler.restart_pool(cr.dbname, update_module=True)
  File "/home/irachid/Bureau/server/openerp/pooler.py", line 39, in restart_pool
    registry = RegistryManager.new(db_name, force_demo, status, update_module, True)
  File "/home/irachid/Bureau/server/openerp/modules/registry.py", line 202, in new
    openerp.modules.load_modules(registry.db, force_demo, status, update_module)
  File "/home/irachid/Bureau/server/openerp/modules/loading.py", line 338, in load_modules
    processed = load_marked_modules(cr, graph, states_to_load, force, status, report, loaded_modules)
  File "/home/irachid/Bureau/server/openerp/modules/loading.py", line 253, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules)
  File "/home/irachid/Bureau/server/openerp/modules/loading.py", line 170, in load_module_graph
    init_module_models(cr, package.name, models)
  File "/home/irachid/Bureau/server/openerp/modules/module.py", line 378, in init_module_models
    result = obj._auto_init(cr, {'module': module_name})
  File "/home/irachid/Bureau/server/openerp/osv/orm.py", line 2832, in _auto_init
    self._add_log_columns(cr)
  File "/home/irachid/Bureau/server/openerp/osv/orm.py", line 3126, in _add_log_columns
    cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, field, field_def))
  File "/home/irachid/Bureau/server/openerp/sql_db.py", line 152, in wrapper
    return f(self, *args, **kwargs)
  File "/home/irachid/Bureau/server/openerp/sql_db.py", line 212, in execute
    res = self._obj.execute(query, params)
ProgrammingError: there is no primary key for referenced table "res_users"

Thanks

Avatar
Discard

Can you copy the complete error of the log in a site like paste on in the answer?

Author

I updated the post with the whole error, thanks

Have you deleted an user without delete relative partner?

Author

I solved the problem by adding a constraint " CONSTRAINT res_users_pkey PRIMARY KEY (id) " to the table res_users, but the same error appeared for other tables, so I need to add this constraint on th Id field to all tables, have you any idea or script to do these in postgres?

Author

No I didn't delete any user, I think that because of the backup of database by openerp web, We have have to backup / restore databases with postgres not throught openerp

I use to backup database by cli every time and I've not problem

Did you restore database before your installation? maybe the problem was this: https://bugs.launchpad.net/openobject-server/+bug/897098/comments/15

Did you previously restore database before your installation? maybe was that: https://bugs.launchpad.net/openobject-server/+bug/897098/comments/15

Best Answer

res_users has a unique index that builds its primary key. Looks like something is wrong with your database, can you try creating another OpenERP database and checking the res_users table has a primary key?

Avatar
Discard
Author

I solved the problem by adding a constraint " CONSTRAINT res_users_pkey PRIMARY KEY (id) " to the table res_users, but the same error appeared for other tables, so I need to add this constraint on th Id field to all tables, have you any idea or script to do these in postgres?

Best Answer

i do have the same problem on an v8 database - seems that an restore of the database through the odoo webinterface killed my db :( the solution with stopping and starting the service does not help me because my backup is already corrupt (i think) is there a simple way to restore all primary keys?

Avatar
Discard