Reputation: 1631
i have following selection fields in my module i want to get string value of selection field. suppose user select 'o'
i want to print O - Original
please provide me any better solution.
type = fields.Selection([
('o', 'O - Original'),
('a', 'A - Amended')],
string="Is this an Original Invoice or Amended Invoice ?"
def get_string_value_of_selection():
if self.type == 'o':
value = "O - Original",
if self.type == 'a':
value = "A - Amended"
print "value = ",value
if user select o
value = O - Original
Upvotes: 1
Views: 10074
Reputation: 1631
it can be archive as follow. working in odoo 9, 10 not tried in 8
print dict(self._fields['type'].selection).get(self.type)
if user select o
output O - Original
Upvotes: 6