diff options
| author | Denis Ledoux <dle@odoo.com> | 2016-12-12 16:27:54 +0100 |
|---|---|---|
| committer | Denis Ledoux <dle@odoo.com> | 2016-12-12 18:18:51 +0100 |
| commit | 487c612f0ca45e48599b317b95acf19ba4f2dddd (patch) | |
| tree | 6419181f01019248ec105b48388454b8c29fc626 /odoo/fields.py | |
| parent | 400a152b9131090a79de31f39d4eea3c349a36db (diff) | |
[FIX] web, orm: allow `0` as key for selection fields
Before this revision,
using a selection field with as possible keys `0`,
such as `require_payment` in `website_quote`,
resulted to the records field values to be stored
as `NULL` instead of `0` in the database.
This leads to the inability:
- To distinguish records with this selection field not set
or set to `0` (as both are stored as `NULL`)
- To search for records with the field set to `0`
(as they are considered not set)
For instance, while having `website_quote` installed,
search for sales orders with `Payment` set to
`Not mandatory on website quote validation`: It won't
return any result, even if you have some.
opw-697454
Diffstat (limited to 'odoo/fields.py')
| -rw-r--r-- | odoo/fields.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/odoo/fields.py b/odoo/fields.py index 427b6c6aa02..2a73ca94daf 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -1744,6 +1744,14 @@ class Selection(Field): return item[1] return False + def convert_to_column(self, value, record): + """ Convert ``value`` from the ``write`` format to the SQL format. """ + if value is None or value is False: + return None + if isinstance(value, unicode): + return value.encode('utf8') + return str(value) + class Reference(Selection): type = 'reference' |
