Skip to content

Commit

Permalink
[FIX] core: revert cb1cfad
Browse files Browse the repository at this point in the history
Due to Cache reimplementation, this commit can't be applied as-it in
version 11.0 and need to be adapted correctly.

Undo PR odoo#19963
  • Loading branch information
KangOl committed Oct 10, 2017
1 parent ee73f6a commit e1104ac
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions odoo/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,18 @@

def copy_cache(records, env):
""" Recursively copy the cache of ``records`` to the environment ``env``. """
src = records.env
todo = defaultdict(set) # {model_name: ids}
done = defaultdict(set) # {model_name: ids}
todo[records._name].update(records._ids)
src, dst = records.env.cache, env.cache
todo, done = set(records), set()
while todo:
model_name = next(iter(todo))
record_ids = todo.pop(model_name) - done[model_name]
done[model_name].update(record_ids)
for name, field in src[model_name]._fields.items():
src_cache = src.cache[field]
dst_cache = env.cache[field]
for record_id in record_ids:
if record_id in src_cache:
# copy the cached value as such
value = dst_cache[record_id] = src_cache[record_id]
if field.relational and isinstance(value, tuple):
todo[field.comodel_name].update(value)
record = todo.pop()
if record not in done:
done.add(record)
target = record.with_env(env)
for field in src.get_fields(record):
value = src.get(record, field)
dst.set(target, field, value)
if value and field.type in ('many2one', 'one2many', 'many2many', 'reference'):
todo.update(field.convert_to_record(value, record))


def resolve_mro(model, name, predicate):
Expand Down

0 comments on commit e1104ac

Please sign in to comment.