From d7020222307cd0d782a51528f5274f0c27597394 Mon Sep 17 00:00:00 2001 From: Ivan Office Date: Mon, 4 Nov 2024 17:36:33 +0800 Subject: [PATCH] =?UTF-8?q?prepare=20#IAXMX0=20app=5Fbase=5Fchinese?= =?UTF-8?q?=EF=BC=8Capp=5Fbase=5Fchinese=5Fwebsite=E5=92=8Cl10n=5Fcn=5Fsta?= =?UTF-8?q?ndard=5Flatest=E5=8D=87=E7=BA=A7=E8=87=B318=20=E7=BD=AE?= =?UTF-8?q?=E9=A1=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_base_chinese/data/ir_default_data.xml | 2 +- app_base_chinese/data/sales_team_data.xml | 6 ++-- app_base_chinese/hooks.py | 28 +++++++++------- .../views/ir_module_module_views.xml | 2 +- app_base_chinese/views/res_partner_views.xml | 33 ++++++++++--------- 5 files changed, 39 insertions(+), 32 deletions(-) diff --git a/app_base_chinese/data/ir_default_data.xml b/app_base_chinese/data/ir_default_data.xml index 34ee2ce6..7576e352 100644 --- a/app_base_chinese/data/ir_default_data.xml +++ b/app_base_chinese/data/ir_default_data.xml @@ -14,7 +14,7 @@ + eval="('product.template', 'type', 'consu')"/> diff --git a/app_base_chinese/data/sales_team_data.xml b/app_base_chinese/data/sales_team_data.xml index 007a20fe..2d70f88a 100644 --- a/app_base_chinese/data/sales_team_data.xml +++ b/app_base_chinese/data/sales_team_data.xml @@ -4,8 +4,8 @@ 中国 - - China - + + + diff --git a/app_base_chinese/hooks.py b/app_base_chinese/hooks.py index ea13386d..a5459bc1 100644 --- a/app_base_chinese/hooks.py +++ b/app_base_chinese/hooks.py @@ -17,6 +17,8 @@ from odoo import api, SUPERUSER_ID, _ +import logging +_logger = logging.getLogger(__name__) def pre_init_hook(cr): """ @@ -26,25 +28,24 @@ def pre_init_hook(cr): pass -def post_init_hook(cr, registry): +def post_init_hook(env): """ 数据初始化,只在安装后执行,更新时不执行 """ try: - env = api.Environment(cr, SUPERUSER_ID, {'active_test': False}) - ids = env['product.category'].sudo().with_context(lang='zh_CN').search([ + ids = env['product.category'].sudo().with_context(lang='zh_CN', active_test=False).search([ ('parent_id', '!=', False) ], order='parent_path') for rec in ids: rec._compute_complete_name() - ids = env['stock.location'].sudo().with_context(lang='zh_CN').search([ + ids = env['stock.location'].sudo().with_context(lang='zh_CN', active_test=False).search([ ('location_id', '!=', False), ('usage', '!=', 'views'), ], order='parent_path') for rec in ids: rec._compute_complete_name() # 超级用户及模板用户改时区为中国 - ids = env['res.users'].sudo().with_context(lang='zh_CN').browse([1,2,3,4,5]) + ids = env['res.users'].sudo().with_context(lang='zh_CN', active_test=False).browse([1, 2, 3, 4, 5]) # rec_extra = env.ref('base.template_portal_user_id') # if rec_extra: # ids += rec_extra @@ -53,18 +54,23 @@ def post_init_hook(cr, registry): 'lang': "zh_CN", }) # 公司价格改人民币 - env = api.Environment(cr, SUPERUSER_ID, {'active_test': True}) - ids = env['res.company'].sudo().search([], limit=1) + ids = env['res.company'].sudo().with_context(active_test=False).search([], limit=1) if ids: - ids.write({'currency_id': env.ref('base.CNY').id}) + try: + ids.write({'currency_id': env.ref('base.CNY').id}) + except Exception as e: + _logger.error('cn: company write currency_id error.') # 价格表改人民币 - ids = env['product.pricelist'].sudo().search([], limit=1) + ids = env['product.pricelist'].sudo().with_context(active_test=False).search([], limit=1) if ids: - ids.write({'currency_id': env.ref('base.CNY').id}) + try: + ids.write({'currency_id': env.ref('base.CNY').id}) + except Exception as e: + _logger.error('cn: pricelist write currency_id error.') except Exception as e: raise Warning(e) -def uninstall_hook(cr, registry): +def uninstall_hook(env): """ 数据初始化,卸载时执行 """ diff --git a/app_base_chinese/views/ir_module_module_views.xml b/app_base_chinese/views/ir_module_module_views.xml index a019e9c8..8ec1b269 100644 --- a/app_base_chinese/views/ir_module_module_views.xml +++ b/app_base_chinese/views/ir_module_module_views.xml @@ -6,7 +6,7 @@ - + diff --git a/app_base_chinese/views/res_partner_views.xml b/app_base_chinese/views/res_partner_views.xml index cb4441f3..38ad8f24 100644 --- a/app_base_chinese/views/res_partner_views.xml +++ b/app_base_chinese/views/res_partner_views.xml @@ -79,22 +79,23 @@ - - app.res.partner.kanban - res.partner - - - - - - -
  • - Credit: - -
  • -
    -
    -
    + + + + + + + + + + + + + + + + +