[ADD] web: warning on incompatible databases
If a database is not an Odoo database or is not the same version Closes #15171
This commit is contained in:
@@ -614,6 +614,7 @@ class Database(http.Controller):
|
||||
d['databases'] = []
|
||||
try:
|
||||
d['databases'] = http.db_list()
|
||||
d['incompatible_databases'] = odoo.service.db.list_db_incompatible(d['databases'])
|
||||
except odoo.exceptions.AccessDenied:
|
||||
monodb = db_monodb()
|
||||
if monodb:
|
||||
|
||||
@@ -129,7 +129,10 @@
|
||||
{% if databases %}
|
||||
<div class="list-group">
|
||||
{% for db in databases %}
|
||||
<a href="/web?db={{ db }}" class="list-group-item">
|
||||
<a href="/web?db={{ db }}" class="list-group-item" >
|
||||
{% if db in incompatible_databases %}
|
||||
<i class="icon fa fa-warning pull-right text-warning" title="This database may not be compatible"></i>
|
||||
{% endif %}
|
||||
{{ db }}
|
||||
{% if manage %}
|
||||
<div class="text-right pull-right">
|
||||
|
||||
@@ -21,6 +21,8 @@ from odoo.exceptions import UserError
|
||||
import odoo.release
|
||||
import odoo.sql_db
|
||||
import odoo.tools
|
||||
from odoo.sql_db import db_connect
|
||||
from odoo.release import version_info
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -342,6 +344,28 @@ def list_dbs(force=False):
|
||||
res.sort()
|
||||
return res
|
||||
|
||||
def list_db_incompatible(databases):
|
||||
""""Check a list of databases if they are compatible with this version of Odoo
|
||||
|
||||
:param databases: A list of existing Postgresql databases
|
||||
:return: A list of databases that are incompatible
|
||||
"""
|
||||
incompatible_databases = []
|
||||
server_version = '.'.join(map(str, version_info[:2]))
|
||||
for database_name in databases:
|
||||
with closing(db_connect(database_name).cursor()) as cr:
|
||||
cr.execute("SELECT 1 FROM information_schema.tables WHERE table_name='ir_module_module'")
|
||||
if cr.fetchone():
|
||||
cr.execute("SELECT latest_version FROM ir_module_module WHERE name=%s", ('base',))
|
||||
base_version = cr.fetchone()[0]
|
||||
# e.g. 10.saas~15
|
||||
if '.'.join(base_version.split('.')[:2]) != server_version:
|
||||
incompatible_databases.append(database_name)
|
||||
else:
|
||||
incompatible_databases.append(database_name)
|
||||
return incompatible_databases
|
||||
|
||||
|
||||
def exp_list(document=False):
|
||||
if not odoo.tools.config['list_db']:
|
||||
raise odoo.exceptions.AccessDenied()
|
||||
|
||||
Reference in New Issue
Block a user