summaryrefslogtreecommitdiff
path: root/odoo/sql_db.py
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2020-03-12 09:42:15 +0000
committerRaphael Collet <rco@odoo.com>2020-03-27 11:48:43 +0000
commit8e44b395707ec54a057388516f9a7fdbc54c0dfb (patch)
tree86300004440a4463d751c5ad186551ff3c05e755 /odoo/sql_db.py
parentaab23e2d310f8e4c7959679629288c4b46b5c0d1 (diff)
[FIX] core: do not flush() with an environment using RequestUID
When routing an HTTP request, the dispatcher uses an environment with a placeholder for the user (the object `RequestUID`). This environment is not supposed to be used after routing has been done. However, the flushing function takes any environment with a given cursor, and it crashes when this environment is chosen (`psycopg2` cannot adapt the type `RequestUID` for `write_uid`), and simply does not make sense. closes odoo/odoo#48495 X-original-commit: da61a64bf6731a08557d23680eabf4d910035ebd Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'odoo/sql_db.py')
-rw-r--r--odoo/sql_db.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/odoo/sql_db.py b/odoo/sql_db.py
index 298bc9f1975..60803fc8f22 100644
--- a/odoo/sql_db.py
+++ b/odoo/sql_db.py
@@ -64,7 +64,8 @@ from inspect import currentframe
def flush_env(cr):
""" Retrieve and flush an environment corresponding to the given cursor """
for env in list(Environment.envs):
- if env.cr is cr:
+ # don't flush() on another cursor or with a RequestUID
+ if env.cr is cr and isinstance(env.uid, int):
env['base'].flush()
break