From 5e1abec2f8abf69b459184e61acffefb40318c5e Mon Sep 17 00:00:00 2001 From: Chill Date: Wed, 22 Mar 2023 11:45:38 +0800 Subject: [PATCH] =?UTF-8?q?[app=5Fbase=5Fchinese]=E5=B0=86=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9A=84=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E9=BB=98=E8=AE=A4=E4=B8=AD=E6=96=87=EF=BC=8C=E4=B8=AD?= =?UTF-8?q?=E5=9B=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_base_chinese/__manifest__.py | 2 +- app_base_chinese/controllers/__init__.py | 2 + app_base_chinese/controllers/database.py | 49 ++++++++++++++ .../static/description/index.html | 2 +- .../database_manager.create_form.qweb.html | 67 +++++++++++++++++++ 5 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 app_base_chinese/controllers/database.py create mode 100644 app_base_chinese/static/src/public/database_manager.create_form.qweb.html diff --git a/app_base_chinese/__manifest__.py b/app_base_chinese/__manifest__.py index 05aa5e8c..1f05ac1e 100644 --- a/app_base_chinese/__manifest__.py +++ b/app_base_chinese/__manifest__.py @@ -18,7 +18,7 @@ { 'name': "App base chinese,中国化基本模块增强", - 'version': '16.23.02.14', + 'version': '16.23.03.22', 'author': 'Sunpop.cn', 'category': 'Base', 'website': 'https://www.sunpop.cn', diff --git a/app_base_chinese/controllers/__init__.py b/app_base_chinese/controllers/__init__.py index 40a96afc..4e65ea1a 100644 --- a/app_base_chinese/controllers/__init__.py +++ b/app_base_chinese/controllers/__init__.py @@ -1 +1,3 @@ # -*- coding: utf-8 -*- + +from . import database diff --git a/app_base_chinese/controllers/database.py b/app_base_chinese/controllers/database.py new file mode 100644 index 00000000..2c63da28 --- /dev/null +++ b/app_base_chinese/controllers/database.py @@ -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) diff --git a/app_base_chinese/static/description/index.html b/app_base_chinese/static/description/index.html index 8e98fcb9..9953dd87 100644 --- a/app_base_chinese/static/description/index.html +++ b/app_base_chinese/static/description/index.html @@ -4,7 +4,7 @@

App base chinese. Local customize for china user

Set all chinese default value. Like Default country, timezone, currency, partner...

-

Lastest update: v16.23.02.14

+

Lastest update: v16.23.03.22

diff --git a/app_base_chinese/static/src/public/database_manager.create_form.qweb.html b/app_base_chinese/static/src/public/database_manager.create_form.qweb.html new file mode 100644 index 00000000..341dba00 --- /dev/null +++ b/app_base_chinese/static/src/public/database_manager.create_form.qweb.html @@ -0,0 +1,67 @@ + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+