diff options
Diffstat (limited to 'odoo/api.py')
| -rw-r--r-- | odoo/api.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/odoo/api.py b/odoo/api.py index 9daf85f0beb..9dd5873d556 100644 --- a/odoo/api.py +++ b/odoo/api.py @@ -878,15 +878,26 @@ class Cache(object): def get_records(self, model, field): """ Return the records of ``model`` that have a value for ``field``. """ - ids = list(self._data[field]) + field_cache = self._data[field] + if field.depends_context: + key = model.env.cache_key(field) + ids = [id_ for id_, value in field_cache.items() if key in value] + else: + ids = list(field_cache) return model.browse(ids) def get_missing_ids(self, records, field): """ Return the ids of ``records`` that have no value for ``field``. """ field_cache = self._data[field] - for record_id in records._ids: - if record_id not in field_cache: - yield record_id + if field.depends_context: + key = records.env.cache_key(field) + for record_id in records._ids: + if key not in field_cache.get(record_id, ()): + yield record_id + else: + for record_id in records._ids: + if record_id not in field_cache: + yield record_id def invalidate(self, spec=None): """ Invalidate the cache, partially or totally depending on ``spec``. """ |
