Skip to content

Commit

Permalink
fixup! [FIX] fastapi: close cursor after rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
lmignon committed Dec 21, 2023
1 parent ce9a58a commit 1a2a5cf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fastapi/error_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@


def _rollback(request: Request, reason: str) -> None:
cr = odoo_env_ctx.get().cr
env = odoo_env_ctx.get()
cr = env.cr
if cr is not None:
_logger.debug("rollback on %s", reason)
cr.rollback()
# Also close the cursor, so `retrying` in service/model.py does not attempt to
# flush.
cr.close()
if not (env.registry.in_test_mode()):
cr.close()


async def _odoo_user_error_handler(
Expand Down

0 comments on commit 1a2a5cf

Please # to comment.