Created
April 13, 2018 07:36
-
-
Save repodevs/535eb574e8fba42611d2f2e29e205a9b to your computer and use it in GitHub Desktop.
Odoo snippet fields.Selection get text name
This file contains hidden or 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
def get_selection_name(models, fields, value): | |
""" Get text value of Selection fields | |
:param models: models of fields | |
:param fields: fields name to get | |
:param value: fields value | |
:return text: Text value of the fields or '' | |
""" | |
res = dict(models.fields_get(allfields=[fields])[fields]['selection'])[value] if value else '' | |
return res | |
# how to use | |
models = self.env['some.model'] | |
fields = 'selection_field' | |
value = models.selection_field | |
print(get_selection_name(models, fields, value)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment