[FIX] orm.browse_record: fields prefetching should ignore m2o pointing to models not loaded yet
This situation can occur due to custom fields (x_...) that are creating shortcuts between objects without respecting the module dependencies. For example a custom m2o fields connecting a partner and a product would fail to be loaded at server startup when only base is loaded, because product.product is not yet available. This can usually be simply ignored, as the prefetching is just an optimization. The custom fields should never be accessed during startup (e.g not function field should use them), so that should never cause any issue. bzr revid: odo@openerp.com-20110216142128-a9f4um5ky8cetl38
This commit is contained in:
parent
0b90edb557
commit
44b019bf76
|
@ -240,6 +240,13 @@ class browse_record(object):
|
|||
# testing to be sure we got the right
|
||||
# object and not the parent one.
|
||||
if not isinstance(value, browse_record):
|
||||
if obj is None:
|
||||
# In some cases the target model is not available yet, so we must ignore it,
|
||||
# which is safe in most cases, this value will just be loaded later when needed.
|
||||
# This situation can be caused by custom fields that connect objects with m2o without
|
||||
# respecting module dependencies, causing relationships to be connected to soon when
|
||||
# the target is not loaded yet.
|
||||
continue
|
||||
new_data[field_name] = browse_record(self._cr,
|
||||
self._uid, value, obj, self._cache,
|
||||
context=self._context,
|
||||
|
@ -272,7 +279,7 @@ class browse_record(object):
|
|||
self._data[result_line['id']].update(new_data)
|
||||
|
||||
if not name in self._data[self._id]:
|
||||
#how did this happen?
|
||||
# How did this happen? Could be a missing model due to custom fields used too soon, see above.
|
||||
self.logger.notifyChannel("browse_record", netsvc.LOG_ERROR,
|
||||
"Fields to fetch: %s, Field values: %s"%(field_names, field_values))
|
||||
self.logger.notifyChannel("browse_record", netsvc.LOG_ERROR,
|
||||
|
|
Loading…
Reference in New Issue