mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
int 17
This commit is contained in:
49
app_base_chinese/controllers/database.py
Normal file
49
app_base_chinese/controllers/database.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import re
|
||||
from lxml import html
|
||||
import odoo
|
||||
import odoo.modules.registry
|
||||
from odoo import http
|
||||
from odoo.exceptions import AccessError
|
||||
from odoo.http import content_disposition, dispatch_rpc, request, Response
|
||||
from odoo.service import db
|
||||
from odoo.tools.misc import file_open, str2bool
|
||||
from odoo.addons.web.controllers.database import Database as Database
|
||||
from odoo.addons.base.models.ir_qweb import render as qweb_render
|
||||
|
||||
DBNAME_PATTERN = '^[a-zA-Z0-9][a-zA-Z0-9_.-]+$'
|
||||
|
||||
|
||||
class Database(Database):
|
||||
|
||||
def _render_template(self, **d):
|
||||
d.setdefault('manage', True)
|
||||
d['insecure'] = odoo.tools.config.verify_admin_password('admin')
|
||||
d['list_db'] = odoo.tools.config['list_db']
|
||||
d['langs'] = odoo.service.db.exp_list_lang()
|
||||
d['countries'] = odoo.service.db.exp_list_countries()
|
||||
d['pattern'] = DBNAME_PATTERN
|
||||
# databases list
|
||||
try:
|
||||
d['databases'] = http.db_list()
|
||||
d['incompatible_databases'] = odoo.service.db.list_db_incompatible(d['databases'])
|
||||
except odoo.exceptions.AccessDenied:
|
||||
d['databases'] = [request.db] if request.db else []
|
||||
|
||||
templates = {}
|
||||
|
||||
with file_open("web/static/src/public/database_manager.qweb.html", "r") as fd:
|
||||
templates['database_manager'] = fd.read()
|
||||
with file_open("web/static/src/public/database_manager.master_input.qweb.html", "r") as fd:
|
||||
templates['master_input'] = fd.read()
|
||||
# with file_open("web/static/src/public/database_manager.create_form.qweb.html", "r") as fd:
|
||||
with file_open("app_base_chinese/static/src/public/database_manager.create_form.qweb.html", "r") as fd:
|
||||
templates['create_form'] = fd.read()
|
||||
|
||||
def load(template_name):
|
||||
fromstring = html.document_fromstring if template_name == 'database_manager' else html.fragment_fromstring
|
||||
return (fromstring(templates[template_name]), template_name)
|
||||
|
||||
return qweb_render('database_manager', d, load)
|
||||
Reference in New Issue
Block a user