Odoo Help

Welcome!

This community 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.

0

openerp 6.1 : no primary key

By
oerp
on 4/24/13, 3:56 PM 3,093 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

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

Francesco OpenCode
on 4/24/13, 4:03 PM

I updated the post with the whole error, thanks

oerp
on 4/25/13, 6:49 AM

Have you deleted an user without delete relative partner?

Francesco OpenCode
on 4/25/13, 6:53 AM

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?

oerp
on 4/25/13, 7:09 AM

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

oerp
on 4/25/13, 8:38 AM

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

Francesco OpenCode
on 4/25/13, 8:41 AM

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

TheBrush
on 2/3/14, 2:22 PM

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

TheBrush
on 2/3/14, 2:25 PM
1

Gustavo

--Gustavo--
950
| 2 1 4
Buenos Aires, Argentina
--Gustavo--

Python developer, big fan of sailing

Gustavo
On 4/24/13, 4:26 PM

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?

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?

oerp
on 4/25/13, 7:08 AM
0
Michael Karrer
On 4/8/15, 5:45 AM

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?

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 4/24/13, 3:56 PM
Seen: 3093 times
Last updated: 4/8/15, 5:45 AM