mirror of
https://github.com/guohuadeng/app-odoo.git
synced 2025-02-23 04:11:36 +02:00
fix 17 hooks
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
from odoo import api, SUPERUSER_ID, _
|
from odoo import api, SUPERUSER_ID, _
|
||||||
|
|
||||||
|
|
||||||
def pre_init_hook(cr):
|
def pre_init_hook(env):
|
||||||
"""
|
"""
|
||||||
数据初始化,只在安装时执行,更新时不执行
|
数据初始化,只在安装时执行,更新时不执行
|
||||||
"""
|
"""
|
||||||
@@ -26,25 +26,24 @@ def pre_init_hook(cr):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def post_init_hook(cr, registry):
|
def post_init_hook(env):
|
||||||
"""
|
"""
|
||||||
数据初始化,只在安装后执行,更新时不执行
|
数据初始化,只在安装后执行,更新时不执行
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
env = api.Environment(cr, SUPERUSER_ID, {'active_test': False})
|
ids = env['product.category'].sudo().with_context(lang='zh_CN', active_test=False).search([
|
||||||
ids = env['product.category'].sudo().with_context(lang='zh_CN').search([
|
|
||||||
('parent_id', '!=', False)
|
('parent_id', '!=', False)
|
||||||
], order='parent_path')
|
], order='parent_path')
|
||||||
for rec in ids:
|
for rec in ids:
|
||||||
rec._compute_complete_name()
|
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),
|
('location_id', '!=', False),
|
||||||
('usage', '!=', 'views'),
|
('usage', '!=', 'views'),
|
||||||
], order='parent_path')
|
], order='parent_path')
|
||||||
for rec in ids:
|
for rec in ids:
|
||||||
rec._compute_complete_name()
|
rec._compute_complete_name()
|
||||||
# 超级用户改时区为中国
|
# 超级用户改时区为中国
|
||||||
ids = env['res.users'].sudo().with_context(lang='zh_CN').browse([1, 2])
|
ids = env['res.users'].sudo().with_context(lang='zh_CN', active_test=False).browse([1, 2])
|
||||||
ids.write({'tz': "Etc/GMT-8"})
|
ids.write({'tz': "Etc/GMT-8"})
|
||||||
# 公司价格改人民币
|
# 公司价格改人民币
|
||||||
ids = env['res.company'].sudo().search([], limit=1)
|
ids = env['res.company'].sudo().search([], limit=1)
|
||||||
@@ -57,7 +56,7 @@ def post_init_hook(cr, registry):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Warning(e)
|
raise Warning(e)
|
||||||
|
|
||||||
def uninstall_hook(cr, registry):
|
def uninstall_hook(env):
|
||||||
"""
|
"""
|
||||||
数据初始化,卸载时执行
|
数据初始化,卸载时执行
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -18,15 +18,15 @@
|
|||||||
from odoo import api, SUPERUSER_ID, _
|
from odoo import api, SUPERUSER_ID, _
|
||||||
|
|
||||||
|
|
||||||
def pre_init_hook(cr):
|
def pre_init_hook(env):
|
||||||
pass
|
pass
|
||||||
# cr.execute("")
|
# cr.execute("")
|
||||||
|
|
||||||
def post_init_hook(cr, registry):
|
def post_init_hook(env):
|
||||||
pass
|
pass
|
||||||
# cr.execute("")
|
# cr.execute("")
|
||||||
|
|
||||||
def uninstall_hook(cr, registry):
|
def uninstall_hook(env):
|
||||||
pass
|
pass
|
||||||
# cr.execute("")
|
# cr.execute("")
|
||||||
|
|
||||||
|
|||||||
@@ -18,21 +18,21 @@
|
|||||||
from odoo import api, SUPERUSER_ID, _
|
from odoo import api, SUPERUSER_ID, _
|
||||||
|
|
||||||
|
|
||||||
def pre_init_hook(cr):
|
def pre_init_hook(env):
|
||||||
try:
|
try:
|
||||||
# 更新企业版指向
|
# 更新企业版指向
|
||||||
sql = "UPDATE ir_module_module SET website = '%s' WHERE license like '%s' and website <> ''" % ('https://www.odooai.cn', 'OEEL%')
|
sql = "UPDATE ir_module_module SET website = '%s' WHERE license like '%s' and website <> ''" % ('https://www.odooai.cn', 'OEEL%')
|
||||||
cr.execute(sql)
|
env.cr.execute(sql)
|
||||||
cr.commit()
|
env.cr.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def post_init_hook(cr):
|
def post_init_hook(env):
|
||||||
# a = check_module_installed(cr, ['app_web_superbar','aaaaa'])
|
# a = check_module_installed(cr, ['app_web_superbar','aaaaa'])
|
||||||
pass
|
pass
|
||||||
# cr.execute("")
|
# cr.execute("")
|
||||||
|
|
||||||
def uninstall_hook(cr, registry):
|
def uninstall_hook(env):
|
||||||
"""
|
"""
|
||||||
数据初始化,卸载时执行
|
数据初始化,卸载时执行
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -17,14 +17,14 @@
|
|||||||
|
|
||||||
from odoo import api, SUPERUSER_ID
|
from odoo import api, SUPERUSER_ID
|
||||||
|
|
||||||
def pre_init_hook(cr):
|
def pre_init_hook(env):
|
||||||
"""
|
"""
|
||||||
数据初始化,只在安装时执行,更新时不执行
|
数据初始化,只在安装时执行,更新时不执行
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def post_init_hook(cr, registry):
|
def post_init_hook(env):
|
||||||
"""
|
"""
|
||||||
数据初始化,只在安装后执行,更新时不执行
|
数据初始化,只在安装后执行,更新时不执行
|
||||||
此处不执行,只是记录,该数据已处理完成
|
此处不执行,只是记录,该数据已处理完成
|
||||||
@@ -32,8 +32,8 @@ def post_init_hook(cr, registry):
|
|||||||
# cr.execute("UPDATE account_account_template set group_id = "
|
# cr.execute("UPDATE account_account_template set group_id = "
|
||||||
# "(select id from account_group where account_group.code_prefix_start=trim(substring(account_account_template.code from 1 for 1)) limit 1);")
|
# "(select id from account_group where account_group.code_prefix_start=trim(substring(account_account_template.code from 1 for 1)) limit 1);")
|
||||||
|
|
||||||
cr.execute("UPDATE account_account set group_id = "
|
env.cr.execute("UPDATE account_account set group_id = "
|
||||||
"(select id from account_group where account_group.code_prefix_start=trim(substring(account_account.code from 1 for 1)) limit 1);")
|
"(select id from account_group where account_group.code_prefix_start=trim(substring(account_account.code from 1 for 1)) limit 1);")
|
||||||
cr.commit()
|
env.cr.commit()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user