跳至内容
菜单
此问题已终结
2 回复
5816 查看

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
2714
1
2月 21
18381
3
8月 24
6026
1
9月 22
1775
2
12月 17
16697