changeset 75d7473e8dd6 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=75d7473e8dd6
description:
Ignore pseudo-field when reading singleton
The default_get method fails when called with non-existing fields.
issue10262
review348161009
diffstat:
trytond/model/modelsingleton.py | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diffs (23 lines):
diff -r e7526f0686ec -r 75d7473e8dd6 trytond/model/modelsingleton.py
--- a/trytond/model/modelsingleton.py Mon Apr 12 19:39:25 2021 +0200
+++ b/trytond/model/modelsingleton.py Mon Apr 12 20:15:13 2021 +0200
@@ -37,13 +37,18 @@
def read(cls, ids, fields_names):
singleton = cls.get_singleton()
if not singleton:
- fname_no_rec_name = [f for f in fields_names if '.' not in f]
+ fname_no_rec_name = [
+ f for f in fields_names
+ if '.' not in f and not f.startswith('_')]
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
res['id'] = ids[0]
+ res['_write'] = True
+ res['_delete'] = True
+ res['_timestamp'] = '0'
return [res]
res = super(ModelSingleton, cls).read([singleton.id], fields_names)
res[0]['id'] = ids[0]