[FIX] manual creation of serialized field from the interface

This commit is contained in:
Benoit
2018-08-20 13:56:29 +02:00
committed by Raphael Collet
parent 48b492b086
commit 03395ea103
2 changed files with 8 additions and 0 deletions
+2
View File
@@ -695,6 +695,8 @@ class IrModelFields(models.Model):
# add compute function if given
if field_data['compute']:
attrs['compute'] = make_compute(field_data['compute'], field_data['depends'])
if field_data.get('sparse'):
attrs['sparse'] = field_data['sparse']
return fields.Field.by_type[field_data['ttype']](**attrs)
+6
View File
@@ -212,9 +212,15 @@ class Registry(Mapping):
if self._fields_by_model is None:
# Query manual fields for all models at once
self._fields_by_model = dic = defaultdict(dict)
id2name = {}
cr.execute('SELECT * FROM ir_model_fields WHERE state=%s', ('manual',))
for field in cr.dictfetchall():
dic[field['model']][field['name']] = field
id2name[field['id']] = field['name']
# compute the attribute 'sparse'
for fields in dic.values():
for name, field in fields.items():
field['sparse'] = id2name.get(field['serialization_field_id'])
return self._fields_by_model[model_name]
def do_parent_store(self, cr):