Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
6018 Zobrazení

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.

Avatar
Zrušit
Nejlepší odpověď

Hi, 

You can follow following link for this:

https://youtu.be/GPhgxxwprA4

Hope it helps,

Thanks

Avatar
Zrušit
Nejlepší odpověď

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



Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
kvě 21
2824
1
úno 21
18596
3
srp 24
6237
1
zář 22
1898
2
pro 17
16935