From ce946dcde04ecc4fb643b514b6c143f0c13416ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 5 Oct 2013 18:04:44 +0200 Subject: [PATCH] Fix ModelSingleton when reading rec_name via default values review1114003 --- trytond/model/modelsingleton.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/trytond/model/modelsingleton.py b/trytond/model/modelsingleton.py index f680832c47..266e18700e 100644 --- a/trytond/model/modelsingleton.py +++ b/trytond/model/modelsingleton.py @@ -30,12 +30,17 @@ class ModelSingleton(ModelStorage): def read(cls, ids, fields_names=None): singleton = cls.get_singleton() if not singleton: - res = cls.default_get(fields_names, with_rec_name=False) if not fields_names: fields_names = cls._fields.keys() + fname_no_rec_name = [f for f in fields_names if '.' not in f] + res = cls.default_get(fname_no_rec_name, + with_rec_name=len(fname_no_rec_name) != len(fields_names)) for field_name in fields_names: if field_name not in res: res[field_name] = None + for field_name in res.keys(): + if field_name not in fields_names: + del res[field_name] res['id'] = ids[0] return [res] res = super(ModelSingleton, cls).read([singleton.id],