Skip to Content
Odoo เมนู
  • ลงชื่อเข้าใช้
  • ทดลองใช้ฟรี
  • แอป
    การเงิน
    • ระบบบัญชี
    • ระบบการออกใบแจ้งหนี้
    • ระบบบัญชีรายจ่าย
    • ระบบการจัดการข้อมูลผ่านสเปรดชีต (BI)
    • เอกสาร
    • ระบบลงลายเซ็น
    การขาย
    • ลูกค้าสัมพันธ์
    • การขาย
    • POS ร้านค้า
    • POS ร้านอาหาร
    • ระบบสมัครสมาชิก
    • การเช่า
    การจัดการเว็บไซต์
    • เครื่องมือสร้างเว็บไซต์
    • ระบบการขายออนไลน์
    • บล็อก
    • ฟอรั่ม
    • ไลฟ์แชท
    • ระบบการอบรมออนไลน์
    ซัพพลายเชน
    • คลังสินค้า
    • ระบบการผลิต
    • PLM
    • ระบบการจัดซื้อ
    • การซ่อมบำรุง
    • ระบบจัดการคุณภาพ
    ทรัพยากรบุคคล
    • ข้อมูลพนักงาน
    • ระบบสรรหาบุคลากร
    • ระบบการลา
    • การประเมิน
    • ระบบการแนะนำพนักงาน
    • ระบบจัดการยานพาหนะ
    การตลาด
    • โซเชียลมาร์เก็ตติ้ง
    • การตลาดผ่านอีเมล
    • ระบบการตลาดผ่าน SMS
    • ระบบการจัดงานอีเวนต์
    • การตลาดแบบอัตโนมัติ
    • ระบบแบบสำรวจ
    การบริการ
    • โปรเจกต์
    • ระบบบันทึกเวลา
    • ระบบการจัดการบริการภาคสนาม
    • ระบบดูแลช่วยเหลือ
    • การวางแผน
    • การนัดหมาย
    ประสิทธิผล
    • ระบบแสดงความคิดเห็น
    • ระบบการอนุมัติ
    • ไอโอที
    • VoIP
    • คลังข้อมูล
    • WhatsApp
    แอปพลิเคชันของบุคคลที่สาม Odoo สตูดิโอ แพลตฟอร์มคลาวด์ของ Odoo
  • อุตสาหกรรม
    การค้าปลีก
    • ร้านขายหนังสือ
    • ร้านขายเสื้อผ้า
    • ร้านขายเฟอร์นิเจอร์
    • ร้านขายของชำ
    • ร้านขายฮาร์ดแวร์
    • ร้านขายของเล่น
    Food & Hospitality
    • บาร์และผับ
    • ร้านอาหาร
    • อาหารฟาสต์ฟู้ด
    • Guest House
    • ตัวแทนจำหน่ายเครื่องดื่ม
    • Hotel
    อสังหาริมทรัพย์
    • Real Estate Agency
    • บริษัทสถาปัตยกรรม
    • บริษัทรับเหมา
    • การจัดการอสังหาริมทรัพย์
    • การจัดสวน
    • สมาคมเจ้าของอสังหาริมทรัพย์
    ปรึกษา
    • สำนักงานบัญชี
    • Odoo พาร์ทเนอร์
    • เอเจนซี่การตลาด
    • สำนักงานกฎหมาย
    • บริการสรรหาบุคลากร
    • การตรวจสอบและการรับรอง
    ระบบการผลิต
    • Textile
    • เหล็ก
    • เฟอร์นิเจอร์
    • อาหาร
    • Brewery
    • ของขวัญขององค์กร
    สุขภาพ & ฟิตเนส
    • ชมรมกีฬา
    • ร้านขายแว่นตา
    • ฟิตเนส
    • ผู้ประกอบวิชาชีพด้านสุขภาพ
    • ร้านขายยา
    • ร้านทำผม
    Trades
    • ช่างซ่อม
    • ฮาร์ดแวร์และการสนับสนุนด้านไอที
    • ระบบพลังงานแสงอาทิตย์
    • ช่างทำรองเท้า
    • บริการทำความสะอาด
    • HVAC Services
    อื่น ๆ
    • Nonprofit Organization
    • สำนักงานสิ่งแวดล้อม
    • ร้านเช่าป้ายโฆษณา
    • การถ่ายภาพ
    • ร้านเช่าจักรยาน
    • ตัวแทนจำหน่ายซอฟต์แวร์
    Browse all Industries
  • คอมมูนิตี้
    ศึกษา
    • บทเรียน
    • เอกสารกำกับโปรแกรม
    • การรับรอง
    • การฝึกอบรม
    • บล็อก
    • พอดแคสต์
    เพิ่มศักยภาพให้กับการศึกษา
    • โปรแกรมการศึกษา
    • Scale Up! Business Game
    • เยี่ยมชม Odoo
    รับซอฟต์แวร์
    • ดาวน์โหลด
    • เปรียบเทียบรุ่น
    • เผยแพร่
    ทำงานร่วมกัน
    • Github
    • ฟอรั่ม
    • ระบบการจัดงานอีเวนต์
    • การแปล
    • ร่วมเป็นพาร์ทเนอร์
    • Services for Partners
    • ลงทะเบียนเพื่อสร้างบัญชีบริษัทของคุณ
    รับบริการ
    • ค้นหาพาร์ทเนอร์
    • ค้นหานักบัญชี
    • พบกับที่ปรึกษา
    • บริการติดตั้งระบบเพื่อใช้งาน
    • ข้อมูลอ้างอิงลูกค้า
    • การสนับสนุน
    • อัปเกรด
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    รับการสาธิต
  • ราคา
  • ช่วยเหลือ

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

  • ลูกค้าสัมพันธ์
  • e-Commerce
  • ระบบบัญชี
  • สินค้าคงคลัง
  • PoS
  • โปรเจกต์
  • MRP
All apps
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
All Posts คน เหรียญรางวัล
แท็ก (View all)
odoo accounting v14 pos v15
เกี่ยวกับฟอรั่มนี้
ช่วยเหลือ

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

ติดตาม

รับการแจ้งเตือนเมื่อมีกิจกรรมในโพสต์นี้

คำถามนี้ถูกตั้งค่าสถานะ
many2onemany2manyodoo16features
3 ตอบกลับ
7071 มุมมอง
อวตาร
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
อวตาร
ละทิ้ง
Oleg Zubak
ผู้เขียน

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
ผู้เขียน

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)

อวตาร
Oleg Zubak
ผู้เขียน คำตอบที่ดีที่สุด

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
อวตาร
ละทิ้ง
อวตาร
Cybrosys Techno Solutions Pvt.Ltd
คำตอบที่ดีที่สุด

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
อวตาร
ละทิ้ง
อวตาร
Mily Shajan
คำตอบที่ดีที่สุด

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
อวตาร
ละทิ้ง
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!

สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!

ลงชื่อ
Related Posts ตอบกลับ มุมมอง กิจกรรม
odoo 16: Many2one - how i can another field Instead Of default แก้ไขแล้ว
many2one odoo16features
อวตาร
อวตาร
1
พ.ค. 23
4387
odoo 16: Many2one field - how to return value of another field Instead Of default 'id'
many2one odoo16features
อวตาร
อวตาร
2
พ.ค. 23
3987
fill drop down on basis of many2many field
many2one many2many
อวตาร
0
ส.ค. 17
4417
many2one unlink without delete (v16)
many2one odoo odoo16features
อวตาร
อวตาร
1
เม.ย. 24
2478
Singleton error for Odoo 16 in action แก้ไขแล้ว
many2many singleton odoo16features
อวตาร
อวตาร
อวตาร
2
มี.ค. 24
2301
คอมมูนิตี้
  • บทเรียน
  • เอกสารกำกับโปรแกรม
  • ฟอรั่ม
โอเพนซอร์ส
  • ดาวน์โหลด
  • Github
  • Runbot
  • การแปล
บริการ
  • โฮสติ้ง odoo.sh เซิร์ฟเวอร์
  • การสนับสนุน
  • อัปเกรด
  • การพัฒนาที่กำหนดเอง
  • การศึกษา
  • ค้นหานักบัญชี
  • ค้นหาพาร์ทเนอร์
  • ร่วมเป็นพาร์ทเนอร์
เกี่ยวกับเรา
  • บริษัทของเรา
  • ทรัพย์สินในรูปของเครื่องหมายการค้า
  • ติดต่อเรา
  • งาน
  • ระบบการจัดงานอีเวนต์
  • พอดแคสต์
  • บล็อก
  • ลูกค้า
  • กฎหมาย • ความเป็นส่วนตัว
  • ความปลอดภัย
الْعَرَبيّة 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 เป็นชุดแอปธุรกิจแบบเปิดที่ครอบคลุมทุกความต้องการของบริษัทของคุณ อาธิ CRM eCommerce ระบบบัญชี ระบบสินค้าคงคลัง ระบบการขายหน้าร้าน โปรเจกต์ และ อีกมากมาย

ความเหนือกว่าอันเป็นเอกลักษณ์ของ Odoo คือการใช้งานที่ง่ายดายและผสานการทำงานอย่างสมบูรณ์แบบในเวลาเดียวกัน

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