Created
August 2, 2021 08:21
-
-
Save sehrishnaz/e667db73cfc219c4aea1a95ca1aee3cd to your computer and use it in GitHub Desktop.
Get Selection field value instead of key in Odoo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Read more in detail: https://learnopenerp.blogspot.com/2021/08/get-selection-field-value-instead-of-key-odoo.html