Ir al contenido
Odoo Menú
  • Inicia 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
    • Inteligencia artificial
    • 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 propiedades
    • 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
  • Comunidad
    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
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

How to move a "manual" model to a custom module?

Suscribirse

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

Se marcó esta pregunta
modulecustomstudioodoo18.0
1 Responder
1288 Vistas
Avatar
Sylvain Albasser

Hello,

We recently moved from Odoo SaaS to Odoo SH (v18.0).


We made a lot of customizations either with Studio or manually (models and fields directly created in dev mode).

We want to move some of those models into proper modules so we can go further in customization.


I found this comment in Odoo Forum (https://www.odoo.com/fr_FR/forum/aide-1/migrating-odoo-studio-fields-to-a-custom-module-287357#answer-287426).

This works fine for a custom field in a non-custom model.

The field's state is changed from "manual" to "base".


But what about a custom model?

How one can move a custom model created manually in Odoo interface (ie. "x_model") to a custom module?


class Model(models.Model):
    _name = "x_model"
x_name = fields.Char('Name', required=True)

^ this code does nothing. Model's and field's states remain "manual".

And a new field added in the module is not created in Odoo after update (no error in logs).


class Model(models.Model):
    _inherit = "x_model"

x_name = fields.Char('Name', required=True)

^ this code generate the following error :

TypeError: Model 'x_model' does not exist in registry.
0
Avatar
Descartar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Mejor respuesta
Hi,

When moving from Odoo SaaS (Studio) to Odoo.sh, custom models created through Studio or developer mode exist only in the database with their state set to “manual”. Defining the same model in Python using _name = "x_model" does not automatically convert it into a module-managed model because Odoo does not take ownership of existing manual models by default. Similarly, using _inherit = "x_model" fails because Studio-created models are not loaded into the registry early enough for Python inheritance during module initialization.

The correct approach is not to override or delete the existing model, but to formally take ownership of it. You should create a proper module defining the same _name as the Studio model, and then use a post_init_hook to update the corresponding records in ir.model and ir.model.fields, changing their state from manual to base. This transfers control of the model and its fields from Studio to your module.

Once this ownership change is done and the module is upgraded, Odoo treats the model as a standard module-based model. You can then safely extend it with additional fields, logic, views, and security rules, and it will behave like any other custom module model. This method is clean, upgrade-safe, and avoids risky operations such as deleting the model, renaming tables, or manually manipulating database structures.

Hope it helps

1
Avatar
Descartar
Sylvain Albasser
Autor

Thanks a lot.

I managed to do this using a migration script.

```
class Model(models.Model):
_name = 'model'

name = fields.Char('Name', required=True)
```

module/migrations/18.0.0.2/pre-custom.py:
```
from odoo.upgrade import util

def migrate(cr, version):

cr.execute("UPDATE ir_model SET state = 'base' where model = 'x_model'")
cr.execute("UPDATE ir_model_fields SET state = 'base' where model = 'x_model' and name = 'x_name'")

util.rename_field(cr, 'x_model', 'x_name', 'name')
util.rename_model(cr, 'x_model', 'model', ignored_m2ms=[])
```

¿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
New application multiple forms using odoo studio odoo10?
module custom studio
Avatar
0
dic 17
4038
custom module on odoo V9 enterprise
module custom odoo
Avatar
0
may 16
5131
odoo studio computed field
studio odoo
Avatar
Avatar
1
may 25
5794
How to custom addons in Odoo is these steps are correct?
custom odoo
Avatar
Avatar
Avatar
2
mar 24
21087
How can we Uninstall odoo module from terminal? Resuelto
module odoo
Avatar
Avatar
Avatar
Avatar
3
sept 25
24801
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 Svenska ภาษาไทย 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.

Sitio web hecho con

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