[FIX] web: invalidate cursor after duplicate

Login in into a database
Access the database manager
Duplicate a database

Internal server error will occur and display user. This should not
happen (even if the database is duplicated just fine), and occur
because after the duplication the connection is dropped but the cursor
will still hold the old reference and then, in the response generation
it will crash.

Invalidating cursor right after the duplication, like what is done after
a 'drop' operation fix the issue

opw-2170974

closes odoo/odoo#44159

X-original-commit: 59553c8595cdaf50a4c6f3ffe4093116d0f48bf1
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2020-01-29 08:15:34 +00:00
parent 5f6571a6fe
commit 35b84646ff
+1
View File
@@ -1098,6 +1098,7 @@ class Database(http.Controller):
if not re.match(DBNAME_PATTERN, new_name):
raise Exception(_('Invalid database name. Only alphanumerical characters, underscore, hyphen and dot are allowed.'))
dispatch_rpc('db', 'duplicate_database', [master_pwd, name, new_name])
request._cr = None # duplicating a database leads to an unusable cursor
return http.local_redirect('/web/database/manager')
except Exception as e:
error = "Database duplication error: %s" % (str(e) or repr(e))