[FIX] [FIX] orm.browse_record: access error due to prefetch of indirectly referenced...
authorOlivier Dony <odo@openerp.com>
Mon, 2 Dec 2013 09:58:45 +0000 (10:58 +0100)
committerOlivier Dony <odo@openerp.com>
Mon, 2 Dec 2013 09:58:45 +0000 (10:58 +0100)
commitf85ca389052193e4ec04e7353bdb6da13a667d45
tree9953bce097e83d5cb29bf6c0e8b1e4f4d60414b5
parent8a3a46fc037d3c9890ff0c96ca7d036a13fd782e
[FIX] [FIX] orm.browse_record: access error due to prefetch of indirectly referenced records (OPW #596679)

  The browse_record prefetching algorithm attempts to
  load data for all known records from the requested
  model (i.e. all IDs present in the browse cache),
  regardless of how indirectly/remotely they were
  referenced. An indirect parent record may therefore
  be prefetched along with its directly browsed children,
  possibly crossing company boundaries involuntarily.

  This patch implements a fallback mechanism when
  the prefetching failed due to what looks like an
  ACL restriction. This being a fuzzy concept at the
  moment, it does its best to only catch a restricted
  set of exceptions, and retry loading the data for
  the directly requested ID only.

  This may cause a small performance penalty in case
  of real errors (with some spurious logging too),
  but should only be triggered in very few cases.

  The downside when this happens is that the prefetching for that
  model gets effectively disabled, requiring multiple
  SQL queries for further access to the data of
  the other directly browsed records.

  This EAFP approach seems safer and faster than
  a LBYL technique where we would have to filter
  all indirect m2o references according to ACLs
  before allowing them to enter the cache.

(This is a backport of revision odo@openerp.com-20131120100627-031fljyf4ckprc9b
from the 7.0 branch).

lp bug: https://launchpad.net/bugs/1238042 fixed
lp bug: https://launchpad.net/bugs/1212429 fixed

bzr revid: odo@openerp.com-20131202095845-1yv86y5olpntz1qg
openerp/osv/orm.py