From d4222b883717260ae84ef39b51ecbc119f357dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Wed, 21 Dec 2016 16:12:29 +0100 Subject: [PATCH] fix getting value of many2one if the value is None --- base_jsonify/models/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base_jsonify/models/models.py b/base_jsonify/models/models.py index fa815a33a..1bbbda166 100644 --- a/base_jsonify/models/models.py +++ b/base_jsonify/models/models.py @@ -32,7 +32,11 @@ def jsonify(self, parser): if field_type in ('one2many', 'many2many'): res[field_name] = rec[field_name].jsonify(subparser) elif field_type == 'many2one': - res[field_name] = rec[field_name].jsonify(subparser)[0] + data = rec[field_name].jsonify(subparser) + if data: + res[field_name] = data[0] + else: + res[field_name] = None else: raise UserError('Wrong parser configuration') else: