filter_by = fields.Selection(selection=_get_filter_possible_values, string='Filter By')
@api.model
@api.onchange('report_type')
def _get_filter_possible_values(self):
# selection = [()]
if str(self.report_type) == 'child_nationality':
return [('nature', _('Nature of Assault')),
('state', _('Case Status')),
('area', _('Area')),
]
elif str(self.report_type) == 'assault_age_groups':
return [('nature', _('Nature of Assault')),
('state', _('Case Status')),
('gender', _('Gender')),
('area', _('Area')),
]
elif str(self.report_type) == 'gender':
return [('area', _('Area')),
]
else:
return [('nature', _('Nature of Assault')),
('state', _('Case Status')),
]
selection box shows always in the else condition
how can i solve this ?
Thanks in Advance
what is the value you are getting in the variable str(self.report_type) inside the function..
when i debug the code it shows as u'child_nationality' type is unicode so i change the type to the string,report_type is selection field