From 7a87739adb5cdad3b5f2ce64bb98d88eab4733c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20BEAU?= Date: Thu, 22 Jun 2017 12:46:43 +0200 Subject: [PATCH] add support of reference fields --- base_jsonify/models/models.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/base_jsonify/models/models.py b/base_jsonify/models/models.py index 08ba30a4a..e6d651e02 100644 --- a/base_jsonify/models/models.py +++ b/base_jsonify/models/models.py @@ -52,10 +52,9 @@ def jsonify(self, parser): field_type = rec._fields[field_name].type if field_type in ('one2many', 'many2many'): res[json_key] = rec[field_name].jsonify(subparser) - elif field_type == 'many2one': - data = rec[field_name].jsonify(subparser) - if data: - res[json_key] = data[0] + elif field_type in ('many2one', 'reference'): + if rec[field_name]: + res[json_key] = rec[field_name].jsonify(subparser)[0] else: res[json_key] = None else: