Pular para o conteúdo
Odoo Menu
  • Entrar
  • Experimente grátis
  • Aplicativos
    Finanças
    • Financeiro
    • Faturamento
    • Despesas
    • Planilhas (BI)
    • Documentos
    • Assinar Documentos
    Vendas
    • CRM
    • Vendas
    • PDV Loja
    • PDV Restaurantes
    • Assinaturas
    • Locação
    Websites
    • Criador de Sites
    • e-Commerce
    • Blog
    • Fórum
    • Chat ao Vivo
    • e-Learning
    Cadeia de mantimentos
    • Inventário
    • Fabricação
    • PLM - Ciclo de Vida do Produto
    • Compras
    • Manutenção
    • Qualidade
    Recursos Humanos
    • Funcionários
    • Recrutamento
    • Folgas
    • Avaliações
    • Indicações
    • Frota
    Marketing
    • Redes Sociais
    • Marketing por E-mail
    • Marketing por SMS
    • Eventos
    • Automação de Marketing
    • Pesquisas
    Serviços
    • Projeto
    • Planilhas de Horas
    • Serviço de Campo
    • Central de Ajuda
    • Planejamento
    • Compromissos
    Produtividade
    • Mensagens
    • Aprovações
    • Internet das Coisas
    • VoIP
    • Conhecimento
    • WhatsApp
    Aplicativos de terceiros Odoo Studio Plataforma Odoo Cloud
  • Setores
    Varejo
    • Loja de livros
    • Loja de roupas
    • Loja de móveis
    • Mercearia
    • Loja de ferramentas
    • Loja de brinquedos
    Comida e hospitalidade
    • Bar e Pub
    • Restaurante
    • Fast Food
    • Hospedagem
    • Distribuidor de bebidas
    • Hotel
    Imóveis
    • Imobiliária
    • Escritório de arquitetura
    • Construção
    • Administração de propriedades
    • Jardinagem
    • Associação de proprietários de imóveis
    Consultoria
    • Escritório de Contabilidade
    • Parceiro Odoo
    • Agência de marketing
    • Escritório de advocacia
    • Aquisição de talentos
    • Auditoria e Certificação
    Fabricação
    • Têxtil
    • Metal
    • Móveis
    • Alimentação
    • Cervejaria
    • Presentes corporativos
    Saúde e Boa forma
    • Clube esportivo
    • Loja de óculos
    • Academia
    • Profissionais de bem-estar
    • Farmácia
    • Salão de cabeleireiro
    Comércio
    • Handyman
    • Hardware e Suporte de TI
    • Sistemas de energia solar
    • Sapataria
    • Serviços de limpeza
    • Serviços de climatização
    Outros
    • Organização sem fins lucrativos
    • Agência Ambiental
    • Aluguel de outdoors
    • Fotografia
    • Aluguel de bicicletas
    • Revendedor de software
    Navegar por todos os setores
  • Comunidade
    Aprenda
    • Tutoriais
    • Documentação
    • Certificações
    • Treinamento
    • Blog
    • Podcast
    Empodere a Educação
    • Programa de educação
    • Scale Up! Jogo de Negócios
    • Visite a Odoo
    Obtenha o Software
    • Baixar
    • Comparar edições
    • Releases
    Colaborar
    • Github
    • Fórum
    • Eventos
    • Traduções
    • Torne-se um parceiro
    • Serviços para parceiros
    • Cadastre seu escritório contábil
    Obtenha os serviços
    • Encontre um parceiro
    • Encontre um Contador
    • Conheça um consultor
    • Serviços de Implementação
    • Referências de Clientes
    • Suporte
    • Upgrades
    Github YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Faça uma demonstração
  • Preços
  • Ajuda

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

  • CRM
  • e-Commerce
  • Financeiro
  • Inventário
  • PoS
  • Projeto
  • MRP
All apps
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
É necessário estar registrado para interagir com a comunidade.
Todas as publicações Pessoas Emblemas
Marcadores (Ver tudo)
odoo accounting v14 pos v15
Sobre este fórum
Ajuda

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

Inscrever

Seja notificado quando houver atividade nesta publicação

Esta pergunta foi sinalizada
many2onemany2manyodoo16features
3 Respostas
7050 Visualizações
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
Cancelar
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 Melhor resposta

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
Cancelar
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Melhor resposta

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
Cancelar
Avatar
Mily Shajan
Melhor resposta

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
Cancelar
Está gostando da discussão? Não fique apenas lendo, participe!

Crie uma conta hoje mesmo para aproveitar os recursos exclusivos e interagir com nossa incrível comunidade!

Inscreva-se
Publicações relacionadas Respostas Visualizações Atividade
odoo 16: Many2one - how i can another field Instead Of default Resolvido
many2one odoo16features
Avatar
Avatar
1
mai. 23
4376
odoo 16: Many2one field - how to return value of another field Instead Of default 'id'
many2one odoo16features
Avatar
Avatar
2
mai. 23
3983
fill drop down on basis of many2many field
many2one many2many
Avatar
0
ago. 17
4409
many2one unlink without delete (v16)
many2one odoo odoo16features
Avatar
Avatar
1
abr. 24
2469
Singleton error for Odoo 16 in action Resolvido
many2many singleton odoo16features
Avatar
Avatar
Avatar
2
mar. 24
2287
Comunidade
  • Tutoriais
  • Documentação
  • Fórum
Open Source
  • Baixar
  • Github
  • Runbot
  • Traduções
Serviços
  • Odoo.sh Hosting
  • Suporte
  • Upgrade
  • Desenvolvimentos personalizados
  • Educação
  • Encontre um Contador
  • Encontre um parceiro
  • Torne-se um parceiro
Sobre nós
  • Nossa empresa
  • Ativos da marca
  • Contato
  • Empregos
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Legal • Privacidade
  • Segurança
الْعَرَبيّة 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 é um conjunto de aplicativos de negócios em código aberto que cobre todas as necessidades de sua empresa: CRM, comércio eletrônico, contabilidade, estoque, ponto de venda, gerenciamento de projetos, etc.

A proposta de valor exclusiva Odoo é ser, ao mesmo tempo, muito fácil de usar e totalmente integrado.

Site feito com

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