Skip to main content

Command Palette

Search for a command to run...

Obtener valores de un campo tipo Selection Odoo

Published
0 min read
Obtener valores de un campo tipo Selection Odoo
amount_type = fields.Selection([
    ('fixed', 'Fixed'),
    ('percentage', 'Percentage of balance')], default='percentage')

def print_value(self):
    # De acuerdo al tipo que se haya guardado en el registro obtendra el valor
    # Ejemplo: si se guardo el amount_type como 'Percentage of balance'
    print(self.amount_type)
    # Out key
    # 'percentage'
    print(dict(self._fields['amount_type'].selection).get(self.amount_type))
    # Out value
    'Percentage of balance'
1.1K views