Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions fastapi/fastapi_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,10 @@ def _manage_odoo_env(self, uid=None):
token = odoo_env_ctx.set(env)
try:
yield
# Flush here to ensure all pending computations are being executed with
# authenticated fastapi user before exiting this context manager, as it
# would otherwise be done using the public user on the commit of the DB
# cursor, what could potentially lead to inconsistencies or AccessError.
env.flush_all()
finally:
odoo_env_ctx.reset(token)