opt event

This commit is contained in:
Ivan Office
2023-11-17 23:17:22 +08:00
parent b436bf91ce
commit 0fe52a3e76
4 changed files with 29 additions and 14 deletions

View File

@@ -31,7 +31,7 @@ def post_init_hook(cr, registry):
数据初始化,只在安装后执行,更新时不执行
"""
try:
env = api.Environment(cr, SUPERUSER_ID, {})
env = api.Environment(cr, SUPERUSER_ID, {'active_test': False})
ids = env['product.category'].sudo().with_context(lang='zh_CN').search([
('parent_id', '!=', False)
], order='parent_path')
@@ -43,9 +43,24 @@ def post_init_hook(cr, registry):
], order='parent_path')
for rec in ids:
rec._compute_complete_name()
# 超级用户改时区为中国
ids = env['res.users'].sudo().with_context(lang='zh_CN').browse([1, 2])
ids.write({'tz': "Etc/GMT-8"})
# 超级用户及模板用户改时区为中国
ids = env['res.users'].sudo().with_context(lang='zh_CN').browse([1,2,3,4,5])
# rec_extra = env.ref('base.template_portal_user_id')
# if rec_extra:
# ids += rec_extra
ids.write({
'tz': "Etc/GMT-8",
'lang': "zh_CN",
})
# 公司价格改人民币
env = api.Environment(cr, SUPERUSER_ID, {'active_test': True})
ids = env['res.company'].sudo().search([], limit=1)
if ids:
ids.write({'currency_id': env.ref('base.CNY').id})
# 价格表改人民币
ids = env['product.pricelist'].sudo().search([], limit=1)
if ids:
ids.write({'currency_id': env.ref('base.CNY').id})
except Exception as e:
raise Warning(e)