[FIX] race condition in ir.ui.menu leading to incomplete menus in web client
[FIX] race condition in ir.ui.menu leading to incomplete menus in web client

See bug, issue occurs with variable frequency when changing between
simple and extended views in a user account (non-administrator at
least): saving the user account leads to a clearing of the menu cache,
this is followed by two search/read in parallel (one to get the full
menu listing and one to get the list of applications for the home
page), which leads to ir_ui_menu.search (thus
ir_ui_menu._filter_visible_menus) being called concurrently, and this
apparently somehow wrecks havoc on some browse_record's caches
yielding to incoherent behaviors (menus which do have children in db
not having children in the browse_record, and thus being pruned from
the list of menus).

Putting a big lock around 1. clear_cache (just in case) and
2. _filter_visible_menu (to make cache-filling essentially atomic)
seems to solve the issue or at least make it disappear, ideally more
time should be spent understanding what breaks in browse_record.

A reentrant lock is needed as _filter_visible_menu may recurse when
accessing e.g. a menu's child_id (which yield a
search([parent_id=menu.id]) and thus a _filter_visible_menu)

gisce/openobject-server,splbio/openobject-server,gisce/openobject-server,splbio/openobject-server,ovnicraft/openerp-server,gisce/openobject-server,MarkusTeufelberger/openobject-server,MarkusTeufelberger/openobject-server,MarkusTeufelberger/openobject-server,splbio/openobject-server,ovnicraft/openerp-server,vnc-biz/openerp-server,vnc-biz/openerp-server