Skip to content

Instantly share code, notes, and snippets.

@sehrishnaz
Created August 2, 2021 08:24
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/ab9b8238cc3e3fe127eda61d6e68c722 to your computer and use it in GitHub Desktop.
Save sehrishnaz/ab9b8238cc3e3fe127eda61d6e68c722 to your computer and use it in GitHub Desktop.
Retrieving Selection Field value instead of key
# Syntax
dict(self.fields_get(allfields=['field_name'])['field_name']['selection'])['key_of_selection_field']
#If you want to get field value in same model in which you are working than use below code
code = dict(self.fields_get(allfields=['state'])['state']['selection'])['key']
#Example
code = dict(self.fields_get(allfields=['code'])['code']['selection'])[self.code]
#If you want to get field value from another model than use below code
code = dict(self.env['your.model'].fields_get(allfields=['state'])['state']['selection'])['key']
#Example
code = dict(self.env['your.model'].fields_get(allfields=['code'])['code']['selection'])[self.code]
@sehrishnaz
Copy link
Author

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