[FIX] base: unlink request.cr after rpc db drop
Start odoo on a specific database, e.g. 'db-example'. Drop it via JSON
or XML RPC. The database is successfully dropped but the RPC fails with
a traceback because it attempts to commit on a database that doesn't
exist anymore.
import requests
admin_passwd = ...
requests.post(
'http://127.0.0.1:8069/jsonrpc',
json={'params': {
'service': 'db',
'method': 'drop',
'args': [
admin_passwd, 'db-example'
]
}}
)
Closes odoo#104527
closes odoo/odoo#105710
X-original-commit: b6e195ccb3a6c37b0d980af159e546bdc67b1e42
Signed-off-by: Julien Castiaux <juc@odoo.com>
This commit is contained in:
@@ -116,8 +116,6 @@ class Database(http.Controller):
|
||||
dispatch_rpc('db', 'change_admin_password', ["admin", master_pwd])
|
||||
try:
|
||||
dispatch_rpc('db', 'drop', [master_pwd, name])
|
||||
if request.db == name:
|
||||
request.env.cr._closed = True # the underlying connection was closed
|
||||
if request.session.db == name:
|
||||
request.session.logout()
|
||||
return request.redirect('/web/database/manager')
|
||||
|
||||
@@ -161,7 +161,7 @@ def retrying(func, env):
|
||||
env.registry.reset_changes()
|
||||
raise
|
||||
|
||||
if not env.cr._closed:
|
||||
if not env.cr.closed:
|
||||
env.cr.commit() # effectively commits and execute post-commits
|
||||
env.registry.signal_changes()
|
||||
return result
|
||||
|
||||
+2
-2
@@ -391,7 +391,7 @@ class Cursor(BaseCursor):
|
||||
_logger.setLevel(level)
|
||||
|
||||
def close(self):
|
||||
if not self._closed:
|
||||
if not self.closed:
|
||||
return self._close(False)
|
||||
|
||||
def _close(self, leak=False):
|
||||
@@ -463,7 +463,7 @@ class Cursor(BaseCursor):
|
||||
|
||||
@property
|
||||
def closed(self):
|
||||
return self._closed
|
||||
return self._closed or self._cnx.closed
|
||||
|
||||
def now(self):
|
||||
""" Return the transaction's timestamp ``NOW() AT TIME ZONE 'UTC'``. """
|
||||
|
||||
Reference in New Issue
Block a user