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

Hi Guys,
I need to get the value of the res.partner model using SQL Query.
Most of the values ​​getting correctly.
The issue is with the selection field. It returns the internal string of the selection field.
I need the string showing in the UI.
How can I get the value of the field selection in Query?

Anyone, please help ...

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

You cannot get that display value directly but either you can use if conditions to compare the keys of the selection and hardcode the display value or you can fetch the selection value (key, value) from the field.

Ex:

self.env['sale.order']._fields['state'].selection


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

Ex:

self.env['sale.order']._fields['state'].selection


Perhaps this approach will be too slow for large requests.

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

The selection text is stored in the ir.model.fields.selection model. If doing it purely through SQL you will need to do a join on this table, matching the field_id and value column and reading the name column.

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Hi Sudhir Arya,

​self.env['sale.order']._fields['state'].selection


this is API method, I need query.

Anyway, As you said I can use like;
 CASE WHEN <Condition> THEN <Value> END 

Thanks.

อวตาร
ละทิ้ง