[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
This commit is contained in:
@@ -955,7 +955,8 @@ var FieldRadio = common.AbstractField.extend(common.ReinitializeFieldMixin, {
|
||||
},
|
||||
get_value: function () {
|
||||
var value = this.get('value');
|
||||
return ((value instanceof Array)? value[0] : value) || false;
|
||||
value = ((value instanceof Array)? value[0] : value);
|
||||
return _.isUndefined(value) ? false : value;
|
||||
},
|
||||
render_value: function () {
|
||||
var self = this;
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user