Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

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

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

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

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
many2onemany2manyodoo16features
3 Odpowiedzi
7098 Widoki
Awatar
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
Awatar
Odrzuć
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)

Awatar
Oleg Zubak
Autor Najlepsza odpowiedź

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
Awatar
Odrzuć
Awatar
Cybrosys Techno Solutions Pvt.Ltd
Najlepsza odpowiedź

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
Awatar
Odrzuć
Awatar
Mily Shajan
Najlepsza odpowiedź

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
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
odoo 16: Many2one - how i can another field Instead Of default Rozwiązane
many2one odoo16features
Awatar
Awatar
1
maj 23
4411
odoo 16: Many2one field - how to return value of another field Instead Of default 'id'
many2one odoo16features
Awatar
Awatar
2
maj 23
3996
fill drop down on basis of many2many field
many2one many2many
Awatar
0
sie 17
4437
many2one unlink without delete (v16)
many2one odoo odoo16features
Awatar
Awatar
1
kwi 24
2496
Singleton error for Odoo 16 in action Rozwiązane
many2many singleton odoo16features
Awatar
Awatar
Awatar
2
mar 24
2309
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة 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 to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

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