Skip to content

Commit

Permalink
Merge PR #407 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by sbidoul
  • Loading branch information
OCA-git-bot committed Dec 21, 2023
2 parents a033014 + a9088c2 commit dfcd19d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
7 changes: 1 addition & 6 deletions fastapi/error_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,10 @@


def _rollback(request: Request, reason: str) -> None:
env = odoo_env_ctx.get()
cr = env.cr
cr = odoo_env_ctx.get().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.
if not (env.registry.in_test_mode()):
cr.close()


async def _odoo_user_error_handler(
Expand Down
5 changes: 1 addition & 4 deletions fastapi/tests/test_fastapi_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ def assert_exception_processed(
demo_app._get_app(), raise_server_exceptions=False
) as test_client, mock.patch.object(
self.env.cr.__class__, "rollback"
) as mock_rollback, mock.patch.object(
self.env.cr.__class__, "close"
) as mock_close:
) as mock_rollback:
response: Response = test_client.get(
"/demo/exception",
params={
Expand All @@ -58,7 +56,6 @@ def assert_exception_processed(
},
)
mock_rollback.assert_called_once()
mock_close.assert_called_once()
self.assertEqual(response.status_code, expected_status_code)
self.assertDictEqual(
response.json(),
Expand Down

0 comments on commit dfcd19d

Please sign in to comment.