Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
2194 Vistas

Hello all,

I have two fields "fee_type" for Fees Type and "calculation_type". Type of both fields is selection. 


fee_type = fields.Selection([('academic', 'Academic '), ('additional', 'Additional'),
('discount', 'Discount'),
('fines', 'Fines')], string='Type')


calculation_type = fields.Selection([('addition', 'Addition'), ('deduction', 'Deduction')],
string='Calculation Type', required=True)

I want that when I select fee_type as "Discount" then calculation_type should be set default to "Deduction".
Here is my code:

@api.onchange('calculation_type')
def _check_calc_type(self):
if self.fee_type == 'discount':
self.calculation_type = 'deduction'
it is not working.
plz help

Avatar
Descartar
Mejor respuesta

Hi,

Update the function like this, Trigger the onchange based on the field fee_type

@api.onchange('fee_type')
def _check_calc_type(self):
if self.fee_type == 'discount':
self.calculation_type = 'deduction'

See how to write onchange for a field in Odoo: Write Onchange Functions in Odoo

Thanks

Avatar
Descartar