Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
3366 มุมมอง

Hello.

I am using the Odoo web browser application, and i have an issue with hiding the drop down list from the many2one field. 

I want the field to know some specific values based on another list, but i don't want it to list the different options in a dropdown list.

I am a bit new to Odoo, can anyone help? 

Thank you in advance.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

you can use the domain attribute to specify a domain filter. This will limit the choices in the many2one field to a specific set of values based on a predefined filter.

you can apply the domain attribute in 2 ways, using python and xml.

Python

my_field = fields.Many2one('other.model', string='My Field')

XML

<field name="my_field" domain="[('some_field', '=', some_value)]" />


Hope this helps

Regards

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

You can pass the condition as a domain. So that you can add some specific values to it based on another list.

state_id = fields.Many2one('res.country.state', string="State", domain="[('country_id', '=', country_id)]")

Regards

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hello Simon Frislev,

You can use Domain filter on field to show specific values in dropdown list of many2one field.

Refer this link to get Help :- https://www.odoo.com/forum/help-1/odoo-14-how-i-can-set-domain-filter-on-many2one-type-field-181671

Thanks, (Siddharth Tarpada)

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.ค. 20
2888
0
มี.ค. 15
3517
1
ก.ค. 24
4677
2
ก.พ. 24
1594
4
มี.ค. 15
11276