0

I need help in something what i want to achieve in Odoo 8. I have 2 selection. A and B. Depending on the value chosen in the selection A i need to show a specific value in the selection B. A piece of code for more clarify:

selection_A = fields.Selection([('fruit', 'Fruit'),
                                 ('branch', 'Branch'),
                                 ('root','Root')],
                                'Tree', required=True)

selection_B = fields.Selection([('deep', 'Deep'),
                                 ('large', 'Large'),
                                 ('orange','Orange')],
                                'Feature', required=True)

So, when the fruit is selected in selection_A i need to show in the selection_B 'Orange' as result. Any suggestion?

Osmani
  • 35
  • 8

1 Answers1

1

You can create a function with @api.onchange('selection_A'). And it will get called when you change the value of selection_A. Then you can write the required value to selection_B.

@api.onchange('selection_A')
def compute_selection_B(self):
    if self.selection_A == 'fruit':
        self.selection_B = 'orange'
Samir
  • 11
  • 3