Ir al contenido
Odoo Menú
  • Iniciar sesión
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • PdV para tiendas
    • PdV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en vivo
    • eLearning
    Cadena de suministro
    • Inventario
    • Manufactura
    • PLM
    • Compras
    • Mantenimiento
    • Calidad
    Recursos humanos
    • Empleados
    • Reclutamiento
    • Vacaciones
    • Evaluaciones
    • Referencias
    • Flotilla
    Marketing
    • Redes sociales
    • Marketing por correo
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyectos
    • Registro de horas
    • Servicio externo
    • Soporte al cliente
    • Planeación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Artículos
    • WhatsApp
    Aplicaciones externas Studio de Odoo Plataforma de Odoo en la nube
  • Industrias
    Venta minorista
    • Librería
    • Tienda de ropa
    • Mueblería
    • Tienda de abarrotes
    • Ferretería
    • Juguetería
    Alimentos y hospitalidad
    • Bar y pub
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidora de bebidas
    • Hotel
    Bienes inmuebles
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión de bienes inmuebles
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Firma contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Manufactura
    • Textil
    • Metal
    • Muebles
    • Comida
    • Cervecería
    • Regalos corporativos
    Salud y ejercicio
    • Club deportivo
    • Óptica
    • Gimnasio
    • Especialistas en bienestar
    • Farmacia
    • Peluquería
    Trades
    • Personal de mantenimiento
    • Hardware y soporte de TI
    • Sistemas de energía solar
    • Zapateros y fabricantes de calzado
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin fines de lucro
    • Agencia para la protección del medio ambiente
    • Alquiler de anuncios publicitarios
    • Fotografía
    • Alquiler de bicicletas
    • Distribuidor de software
    Descubre todas las industrias
  • Odoo Community
    Aprende
    • Tutoriales
    • Documentación
    • Certificaciones
    • Capacitación
    • Blog
    • Podcast
    Fortalece la educación
    • Programa educativo
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtén el software
    • Descargar
    • Compara ediciones
    • Versiones
    Colabora
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Conviértete en partner
    • Servicios para partners
    • Registra tu firma contable
    Obtén servicios
    • Encuentra un partner
    • Encuentra un contador
    • Contacta a un consultor
    • Servicios de implementación
    • Referencias de clientes
    • Soporte
    • Actualizaciones
    GitHub YouTube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicita 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
  • Proyectos
  • 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

v17: Module upgrade fails due to Many2one-related field

Suscribirse

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

Se marcó esta pregunta
many2oneupgraderelated_fieldsv17
1 Responder
460 Vistas
Avatar
Peter Schiffmann

We have 2 custom modules A and B:

Module A extends res.partner by a simple selection from a static list of predefined values:

class Partner(models.Model):
_inherit = "res.partner"
status = fields.Selection(STATUS, default="0")

Module B (depending on A by its manifest) extends account.move and relates to the status of a company via a Many2One:

class AccountMove(models.Model):
_inherit = "account.move"
partner_company_id = fields.Many2one("res.partner", compute="_compute_parent", store=True)
status = fields.Selection(related="partner_company_id.status", store=True)

After later changes to module A we want to upgrade it in Odoo via the 'Apps' menu, but we get an error message (the same we get when we try to upgrade module B with no changes at all).

File "/odoo17/odoo/fields.py", line 606, in setup_related
    raise KeyError(
KeyError: 'Field status referenced in related field definition account.move.status does not exist.'

Can we fix this somehow? Or is this an Odoo bug, due to the Many2One->related combination that Odoo can not handle correctly on the upgrade / transition?

0
Avatar
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta

Hi,



This issue occurs because of how Odoo handles module dependencies and related fields during upgrades. In your setup, Module A adds the status field to res.partner, while Module B creates a related field in account.move that depends on res.partner.status. When you upgrade Module A, Odoo temporarily reloads its model definitions, and since Module B’s related field still references a field that hasn’t been fully reloaded, it triggers a KeyError. This isn’t exactly a bug in your code but rather a limitation of Odoo’s registry initialization process when dealing with interdependent modules.


To fix it, the simplest method is to upgrade the modules in the correct order, upgrade Module A first, then Module B. If the Apps interface doesn’t work, this can be done using terminal commands with -u module_a followed by -u module_b.


If that doesn’t resolve it, you can temporarily disable the related field in Module B (by removing the related parameter), upgrade Module A, and then restore the related field after Module A has loaded successfully.


A more robust solution is to replace the related field with a computed field that depends on partner_company_id.status. This avoids hard registry dependencies during startup and ensures that upgrades run smoothly regardless of the module loading order.


Finally, make sure Module B’s manifest explicitly declares a dependency on Module A. In short, this issue is caused by Odoo’s dependency loading sequence, and the best long-term fix is to use a computed field or carefully manage module upgrade order.


Hope it helps

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

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

Registrarse
Publicaciones relacionadas Respuestas Vistas Actividad
v17: how to add related field in this scenario?
related_fields v17
Avatar
Avatar
1
ene 24
2953
When is the scheduled date for the production upgrade to Odoo 17.0 on odoo.sh? Resuelto
upgrade v17
Avatar
Avatar
1
ene 24
2052
Write to Record in Related Field of Many2One Relationship
many2one related_fields
Avatar
0
may 15
7223
Showing only name in Many2one field relation res.parter Resuelto
many2one res.partner v17
Avatar
Avatar
1
jul 24
4047
Send a value from context one2many
many2one related_fields odoo15
Avatar
0
may 24
1772
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento en Odoo.sh
  • Soporte
  • Actualizaciones del software
  • Desarrollos personalizados
  • Educación
  • Encuentra un contador
  • Encuentra un partner
  • Conviértete en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contáctanos
  • Empleos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • 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 estar 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