Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
3228 Vizualizări

when the user select the "Aérrienne" option i just want to add new options to the type_transport select


```python

mode_transport = fields.Selection([ ('Routière\Maritime','Routière\Maritime'), ('Routière','Routière'),('Aérrienne','Aérrienne') ],string="Mode de Transport") type_transport = fields.Selection([('test1','test1')],string="responsible"

@api.onchange("mode_transport")

def _set_type_transport(self):

 if self.mode_trasport == False

  pass

 elif self.mode_transport == 'Aérrienne'

  self.type_transport = fields.Selection(add_selection=[("new option","new option")])

```


Imagine profil
Abandonează
Cel mai bun răspuns
_type_transport = [('test1','test1')]

mode_transport = fields.Selection([('Routière\Maritime', 'Routière\Maritime'), ('Routière', 'Routière'), ('Aérrienne', 'Aérrienne')],string="Mode de Transport")
type_transport = fields.Selection(lambda self: self._type_transport,string="responsible")

@api.onchange("mode_transport")
def _set_type_transport(self):
if self.mode_trasport == False :
return
elif
self.mode_transport == 'Aérrienne' :
self.type_transport =self._type_transport.append(("new option","new option"))

Imagine profil
Abandonează

You need to check to see if the option has already been added, such case may happen when you select the same option more than once.
And also you page need to be reloaded for the added options to show.

Related Posts Răspunsuri Vizualizări Activitate
1
iun. 25
1702
3
iul. 25
3329
1
mai 25
1470
1
mai 25
1729
4
mai 25
2868