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

[SOLVED] How to make visible selected values in many2one or many2many fields on Settings page in Odoo 16

Suscribirse

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

Se marcó esta pregunta
many2onemany2manyodoo16features
3 Respuestas
7063 Vistas
Avatar
Oleg Zubak

I have a setting page for my custom module, there I choose from many2one field some value. All works fine and data are stored in Database. But after saving values or reloading the web browser page selected values are not displayed. Is there any method how to display selected and stored data?

0
Avatar
Descartar
Oleg Zubak
Autor

Thanks to all for answers, but this methods what all of provide are not display values after they were stored into ir config parameter module DB. The actual problem is that after reloading the page or re-enter in Settings page after saving the values , the selected before fields values are not shown. I have checked DB of ir config parameter and it`s sure that values are correctly stored. Maybe its for security reasons Odoo has disable this in Odoo 16. Thanks in advance for answers.

``` python

class ResConfigSettings(models.TransientModel):

​_inherit = 'res.config.settings'

​drop_down = fields.Many2one('group.info', readonly=False)
​allowed_user_ids = fields.Many2many('user.info', readonly=False, store=True)

​def get_values(self):

​ ​res = super(ResConfigSettings, self).get_values()
​ ​config_parameter = self.env['ir.config_parameter'].sudo()

​ ​group_def =config_parameter.get_param('group.info.drop_down')

​ ​allowed_user=config_parameter.get_param('bot_module.allowed_user_ids')
​ ​allowed_user_ids = []

​ ​if allowed_user_default and isinstance(allowed_user_default, str):

​ ​ ​allowed_user_ids = literal_eval(allowed_user)
​ ​res.update({

​ ​ ​'drop_down': group_def,'

​ ​ ​allowed_user_ids': [(6, 0, allowed_user_ids)],

​ ​})

​ ​return res

​def set_values(self):
​ ​res = super(ResConfigSettings, self).set_values()
​ ​config_parameter = self.env['ir.config_parameter'].sudo()

​ ​config_parameter.set_param('group.info.drop_down', self.drop_down.id)
​ ​config_parameter.set_param(

​ ​'bot_module.allowed_user_id',

​ ​self.allowed_user_ids.ids)
​ ​return res

```

Here is a peace of code that I use to set and get values.

Oleg Zubak
Autor

Thanks to everybody for the answers. I solve my issue for Many2many a many2one :
config_parameter = self.env['ir.config_parameter'].sudo()
config_parameter.set_param('user_client.keywords', self.keywords.ids)
config_parameter.set_param('user_client.group_and_chat', self.group.ids)

Avatar
Oleg Zubak
Autor Mejor respuesta

Thanks to all for answers, but this methods what all of provide are not display values after they were stored into ir config parameter module DB. The actual problem is that after reloading the page or re-enter in Settings page after saving the values , the selected before fields values are not shown. I have checked DB of ir config parameter and it`s sure that values are correctly stored. Maybe its for security reasons Odoo has disable this in Odoo 16. Thanks in advance for answers.

 ``` python

class ResConfigSettings(models.TransientModel):

​_inherit = 'res.config.settings'


​drop_down = fields.Many2one('group.info', readonly=False)
​allowed_user_ids = fields.Many2many('user.info', readonly=False, store=True)


​def get_values(self):

​ ​res = super(ResConfigSettings, self).get_values()
​ ​config_parameter = self.env['ir.config_parameter'].sudo()

​ ​group_def =config_parameter.get_param('group.info.drop_down')

​ ​allowed_user=config_parameter.get_param('bot_module.allowed_user_ids')
​ ​allowed_user_ids = []

​ ​if allowed_user_default and isinstance(allowed_user_default, str):

​ ​ ​allowed_user_ids = literal_eval(allowed_user)
​ ​res.update({

​ ​ ​'drop_down': group_def,'

​ ​ ​allowed_user_ids': [(6, 0, allowed_user_ids)], 

​ ​})

​ ​return  res


​def set_values(self):
​ ​res = super(ResConfigSettings, self).set_values()
​ ​config_parameter = self.env['ir.config_parameter'].sudo()

​ ​config_parameter.set_param('group.info.drop_down', self.drop_down.id)
​ ​config_parameter.set_param(

​ ​'bot_module.allowed_user_id', 

​ ​self.allowed_user_ids.ids)
​ ​return res

```

Here is a peace of code that I use to set and get values.

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

Hi,

I can provide a reference to a blog post that explains how to make selected values visible in many2one or many2many fields on the settings page in Odoo 16.
Here is the link to the blog post:

https://www.cybrosys.com/blog/how-to-save-many2many-field-in-odoo-v15-settings

The blog post explains how to create a configuration settings model in Odoo 16 with many2one or many2many fields, and how to store and retrieve the selected values of those fields in the ir.config_parameter model. The blog post also provides a sample code that demonstrates how to display the selected values of many2one or many2many fields on the settings page.

The blog post that I referred to is for Odoo 15, but the same concepts and code should work in Odoo 16 as well since they are both based on the same framework.

Regards

0
Avatar
Descartar
Avatar
Mily Shajan
Mejor respuesta

Hi 

To store the value saved in the res.config.settings model you need to set the method get_values and set_values to those fields.

Try this example

class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'

division_user = fields.Many2one("res.users")
hr_user = fields.Many2one("res.users")

def set_values(self):
res = super(ResConfigSettings, self).set_values()
self.env['ir.config_parameter'].sudo().set_param('module_name.division_user', int(self.division_user.id))
self.env['ir.config_parameter'].sudo().set_param('module_name.hr_user', int(self.hr_user.id))
return res

def get_values(self):
res = super(ResConfigSettings, self).get_values()
get_param = self.env['ir.config_parameter'].sudo().get_param
res['division_user'] = int(get_param('module_name.division_user'))
res['hr_user'] = int(get_param('module_name.hr_user'))
return res

https://www.odoo.com/forum/help-1/problems-on-saving-data-to-res-config-settings-in-odoo-12-153308


Hope this helps 

Regards

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
odoo 16: Many2one - how i can another field Instead Of default Resuelto
many2one odoo16features
Avatar
Avatar
1
may 23
4382
odoo 16: Many2one field - how to return value of another field Instead Of default 'id'
many2one odoo16features
Avatar
Avatar
2
may 23
3985
fill drop down on basis of many2many field
many2one many2many
Avatar
0
ago 17
4416
many2one unlink without delete (v16)
many2one odoo odoo16features
Avatar
Avatar
1
abr 24
2476
Singleton error for Odoo 16 in action Resuelto
many2many singleton odoo16features
Avatar
Avatar
Avatar
2
mar 24
2295
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