diff options
| author | Raphael Collet <rco@odoo.com> | 2020-03-26 08:53:22 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2020-03-27 11:48:34 +0000 |
| commit | aab23e2d310f8e4c7959679629288c4b46b5c0d1 (patch) | |
| tree | 0eeed6598fcc540fd57eebf5a27554fdc99f5f63 /odoo/http.py | |
| parent | dac062a49010e7383002d2f3b3f2cb207a9b304b (diff) | |
[FIX] http: don't flush() outside of a checked call
When a serialization error occurs in a given code context, the call is
retried. However, currently the environment is flushed outside this
context, which may cause a serialization error that is not handled by a
retry. Move the flush inside the checked call to catch all
serialization errors, and handle them properly.
X-original-commit: 6197bfb3b2d51873416780c96cd4cb538a1f219c
Diffstat (limited to 'odoo/http.py')
| -rw-r--r-- | odoo/http.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/odoo/http.py b/odoo/http.py index 3b2a6468cf3..085eaa29240 100644 --- a/odoo/http.py +++ b/odoo/http.py @@ -49,6 +49,7 @@ import odoo from odoo import fields from .service.server import memory_info from .service import security, model as service_model +from .sql_db import flush_env from .tools.func import lazy_property from .tools import ustr, consteq, frozendict, pycompat, unique, date_utils from .tools.mimetypes import guess_mimetype @@ -347,6 +348,11 @@ class WebRequest(object): if isinstance(result, Response) and result.is_qweb: # Early rendering of lazy responses to benefit from @service_model.check protection result.flatten() + if self._cr is not None: + # flush here to avoid triggering a serialization error outside + # of this context, which would not retry the call + flush_env(self._cr) + self._cr.precommit() return result if self.db: |
