Skip to content

Instantly share code, notes, and snippets.

@sehrishnaz
Created August 2, 2021 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sehrishnaz/e667db73cfc219c4aea1a95ca1aee3cd to your computer and use it in GitHub Desktop.
Save sehrishnaz/e667db73cfc219c4aea1a95ca1aee3cd to your computer and use it in GitHub Desktop.
Get Selection field value instead of key in Odoo
#syntax
some_variable = self._fields['your_selection_field'].selection
#Example
code = self._fields['code'].selection
# output: [('a', 'A'), ('b','B'), ('c','C')]
#To convert into python dictionary we will use dict keyword provided by python.
code_dict = dict(code)
#To get actual value we will pass key to above dictionary.
name = code_dict.get(self.code)
@sehrishnaz
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment