Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Información
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

Database restore error in V12e - psycopg2.errors.InvalidForeignKey: there is no unique constraint matching given keys for referenced table "res_users"

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
v12epsycopg2.errors
6 Respuestas
20471 Vistas
Avatar
Muhammed Fasil

Error : psycopg2.errors.InvalidForeignKey: there is no unique constraint matching given keys for referenced table "res_users"

occurred after restored database of odoo12 enterprise version.




1
Avatar
Descartar
Avatar
Rafiul
Mejor respuesta

Connect to PostgreSQL database using terminal with odoo as user. Then select your odoo database with

\c YOUR_ODOO_DATABASE_NAME

command and then run the below sql command,

alter table res_users add primary key (id);
1
Avatar
Descartar
Avatar
Israr
Mejor respuesta

psycopg2.errors.InvalidForeignKey: there is no unique constraint matching given keys for referenced table "res_users" answer its becuase of odoo conf soft and hard limits i resolve this issue by increase limit_memory_hard = 9999999999 limit_memory_soft = 9999999999 limit_request = 8192 limit_time_cpu = 1200 limit_time_real = 1200

0
Avatar
Descartar
Avatar
Hamza YAYA
Mejor respuesta

I had the same issue after restored a database

my env : odoo v15 enterprise version with postgresql v14

i used the answer of rafiul but i found that the is more than one hundred table with missing primary key after restored.

So after found this answer https://stackoverflow.com/questions/60523568/add-primary-key-to-all-tables-in-database-that-dont-have-one-yet , i customized the command to have this one. You can use it in case you want to set the column id as a primary key for all table where primary key is missing.

DO $$
DECLARE row RECORD;
BEGIN
FOR row IN
SELECT tab.table_schema, tab.table_name
FROM information_schema.tables tab
LEFT JOIN information_schema.table_constraints tco
ON tab.table_schema = tco.table_schema
AND tab.table_name = tco.table_name
AND tco.constraint_type = 'PRIMARY KEY'
WHERE tab.table_type = 'BASE TABLE'
AND tab.table_schema not in ('pg_catalog', 'information_schema')
AND tco.constraint_name is null
AND tab.table_name in (SELECT table_name FROM information_schema.columns WHERE column_name = 'id')
ORDER BY table_schema, table_name
LOOP
EXECUTE 'ALTER TABLE "' || row.table_schema || '"."' || row.table_name || '" ADD CONSTRAINT PK_' || row.table_name || ' PRIMARY KEY (ID)';
END LOOP;
END;
$$;

YOU CAN RUN IT IN PGADMIN



0
Avatar
Descartar
Avatar
Sadok Abouda
Mejor respuesta

did you find any solution 
if you have, please tell me how to fix it

0
Avatar
Descartar
Israr

yes
psycopg2.errors.InvalidForeignKey: there is no unique constraint matching given keys for referenced table "res_users" answer its becuase of odoo conf soft and hard limits
i resolve this issue by increase
limit_memory_hard = 9999999999
limit_memory_soft = 9999999999
limit_request = 8192
limit_time_cpu = 1200
limit_time_real = 1200

Israr

most of this problem comes after restoring db. but do not entirely restore

Avatar
Ibrahim Zool Odoo
Mejor respuesta

hello ,  see below answers i hope will help you :

https://stackoverflow.com/questions/11966420/what-is-causing-error-there-is-no-unique-constraint-matching-given-keys-for-ref

0
Avatar
Descartar
Avatar
Moaaz Gafar
Mejor respuesta

see This https://bugs.launchpad.net/openobject-server/+bug/897098

-1
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
Enable delete option in database manager
v12e
Avatar
0
abr 21
4
psycopg2.errors.NumericValueOutOfRange
migration psycopg2.errors odoo16features
Avatar
Avatar
1
abr 24
3809
odoo 15 development error
development error v15 psycopg2.errors
Avatar
Avatar
1
jul 24
4713
psycopg2.errors.DatatypeMismatch: COALESCE types text and integer cannot be matched
error module v15 psycopg2.errors
Avatar
0
feb 23
15
Internal transfer in v12 odoo
warehouses v12 v12e InternalTransfer
Avatar
0
ago 22
2518
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now