Skip to Content
Odoo Menú
  • Registra entrada
  • Prova-ho gratis
  • Aplicacions
    Finances
    • Comptabilitat
    • Facturació
    • Despeses
    • Full de càlcul (IA)
    • Documents
    • Signatura
    Vendes
    • CRM
    • Vendes
    • Punt de venda per a botigues
    • Punt de venda per a restaurants
    • Subscripcions
    • Lloguer
    Imatges de llocs web
    • Creació de llocs web
    • Comerç electrònic
    • Blog
    • Fòrum
    • Xat en directe
    • Aprenentatge en línia
    Cadena de subministrament
    • Inventari
    • Fabricació
    • PLM
    • Compres
    • Manteniment
    • Qualitat
    Recursos humans
    • Empleats
    • Reclutament
    • Absències
    • Avaluacions
    • Recomanacions
    • Flota
    Màrqueting
    • Màrqueting Social
    • Màrqueting per correu electrònic
    • Màrqueting per SMS
    • Esdeveniments
    • Automatització del màrqueting
    • Enquestes
    Serveis
    • Projectes
    • Fulls d'hores
    • Servei de camp
    • Suport
    • Planificació
    • Cites
    Productivitat
    • Converses
    • Validacions
    • IoT
    • VoIP
    • Coneixements
    • WhatsApp
    Aplicacions de tercers Odoo Studio Plataforma d'Odoo al núvol
  • Sectors
    Comerç al detall
    • Llibreria
    • Botiga de roba
    • Botiga de mobles
    • Botiga d'ultramarins
    • Ferreteria
    • Botiga de joguines
    Food & Hospitality
    • Bar i pub
    • Restaurant
    • Menjar ràpid
    • Guest House
    • Distribuïdor de begudes
    • Hotel
    Real Estate
    • Real Estate Agency
    • Estudi d'arquitectura
    • Construcció
    • Gestió immobiliària
    • Jardineria
    • Associació de propietaris de béns immobles
    Consulting
    • Accounting Firm
    • Partner d'Odoo
    • Agència de màrqueting
    • Bufet d'advocats
    • Captació de talent
    • Auditoria i certificació
    Fabricació
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Regals corporatius
    Salut i fitness
    • Club d'esport
    • Òptica
    • Centre de fitness
    • Especialistes en benestar
    • Farmàcia
    • Perruqueria
    Trades
    • Servei de manteniment
    • Hardware i suport informàtic
    • Solar Energy Systems
    • Shoe Maker
    • Serveis de neteja
    • HVAC Services
    Others
    • Nonprofit Organization
    • Agència del medi ambient
    • Lloguer de panells publicitaris
    • Fotografia
    • Lloguer de bicicletes
    • Distribuïdors de programari
    Browse all Industries
  • Comunitat
    Aprèn
    • Tutorials
    • Documentació
    • Certificacions
    • Formació
    • Blog
    • Pòdcast
    Potenciar l'educació
    • Programa educatiu
    • Scale-Up! El joc empresarial
    • Visita Odoo
    Obtindre el programari
    • Descarregar
    • Comparar edicions
    • Novetats de les versions
    Col·laborar
    • GitHub
    • Fòrum
    • Esdeveniments
    • Traduccions
    • Converteix-te en partner
    • Services for Partners
    • Registra la teva empresa comptable
    Obtindre els serveis
    • Troba un partner
    • Troba un comptable
    • Contacta amb un expert
    • Serveis d'implementació
    • Referències del client
    • Suport
    • Actualitzacions
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Programar una demo
  • Preus
  • Ajuda

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

  • CRM
  • e-Commerce
  • Comptabilitat
  • Inventari
  • PoS
  • Projectes
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Etiquetes (View all)
odoo accounting v14 pos v15
About this forum
Ajuda

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

Subscriure's

Get notified when there's activity on this post

This question has been flagged
many2onemany2manyodoo16features
3 Respostes
7055 Vistes
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 Best Answer

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
Best Answer

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
Best Answer

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
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrar-se
Related Posts Respostes Vistes Activitat
odoo 16: Many2one - how i can another field Instead Of default Solved
many2one odoo16features
Avatar
Avatar
1
de maig 23
4377
odoo 16: Many2one field - how to return value of another field Instead Of default 'id'
many2one odoo16features
Avatar
Avatar
2
de maig 23
3983
fill drop down on basis of many2many field
many2one many2many
Avatar
0
d’ag. 17
4411
many2one unlink without delete (v16)
many2one odoo odoo16features
Avatar
Avatar
1
d’abr. 24
2472
Singleton error for Odoo 16 in action Solved
many2many singleton odoo16features
Avatar
Avatar
Avatar
2
de març 24
2290
Community
  • Tutorials
  • Documentació
  • Fòrum
Codi obert
  • Descarregar
  • GitHub
  • Runbot
  • Traduccions
Serveis
  • Allotjament a Odoo.sh
  • Suport
  • Actualització
  • Desenvolupaments personalitzats
  • Educació
  • Troba un comptable
  • Troba un partner
  • Converteix-te en partner
Sobre nosaltres
  • La nostra empresa
  • Actius de marca
  • Contacta amb nosaltres
  • Llocs de treball
  • Esdeveniments
  • Pòdcast
  • Blog
  • Clients
  • Informació legal • Privacitat
  • Seguretat
الْعَرَبيّة 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 és un conjunt d'aplicacions empresarials de codi obert que cobreix totes les necessitats de la teva empresa: CRM, comerç electrònic, comptabilitat, inventari, punt de venda, gestió de projectes, etc.

La proposta única de valor d'Odoo és ser molt fàcil d'utilitzar i estar totalment integrat, ambdues alhora.

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