跳至內容
選單
此問題已被標幟
2 回覆
6024 瀏覽次數

Is it possible to populate a selection field dynamically based on another field?
For example:

I have an integer field that the user populate with the value 3.

I want that the selection field automatically will be populated with the choices 1,2,3.

Thank you.

頭像
捨棄
最佳答案

Hi, 

You can follow following link for this:

https://youtu.be/GPhgxxwprA4

Hope it helps,

Thanks

頭像
捨棄
最佳答案

use like this

field_name = fields.Selection(selection=lambda self: self.dynamic_selection(), string="Scheme", tracking=True)
def dynamic_selection(self):
        objs = self.env['object.name'].sudo().search([])
        selection = [(rec.scheme, rec.scheme) for rec in objs]
        return selection



頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
5月 21
2826
1
2月 21
18604
3
8月 24
6249
1
9月 22
1905
2
12月 17
16937