From c51bb8ca1b8ba0b222cf289c7d960b3ad9489b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Fri, 23 Jun 2017 15:46:44 +0200 Subject: [PATCH] base_jsonify: remove False for int, float, string --- base_jsonify/models/models.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/base_jsonify/models/models.py b/base_jsonify/models/models.py index e6d651e02..60b41ccb2 100644 --- a/base_jsonify/models/models.py +++ b/base_jsonify/models/models.py @@ -44,12 +44,18 @@ def jsonify(self, parser): """ result = [] + empty_value = { + 'char': '', + 'int': 0, + 'float': 0, + } + for rec in self: res = {} for field in parser: field_name, json_key, subparser = __parse_field(field) + field_type = rec._fields[field_name].type if subparser: - field_type = rec._fields[field_name].type if field_type in ('one2many', 'many2many'): res[json_key] = rec[field_name].jsonify(subparser) elif field_type in ('many2one', 'reference'): @@ -61,6 +67,8 @@ def jsonify(self, parser): raise UserError(_('Wrong parser configuration')) else: res[json_key] = rec[field_name] + if not res[json_key] and field_type in empty_value: + res[json_key] = empty_value[field_type] result.append(res) return result