中国本土应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2KB

  1. # -*- coding: utf-8 -*-
  2. from . import models
  3. from . import controllers
  4. from odoo import api, SUPERUSER_ID
  5. def post_init_hook(cr, registry):
  6. # ! 在安装好模块之后:
  7. # ~ 1. 设置所有公司的默认主题
  8. # ~ 2. 设置所有公司对应的系统用户的默认用户菜单项目
  9. # ~ 3. 设置系统用户的默认主题,
  10. # ~ 4. 跳转 "设置" 菜单
  11. env = api.Environment(cr, SUPERUSER_ID, {})
  12. domain = ["|", ("active", "=", False), ("active", "=", True)]
  13. companies = env["res.company"]
  14. theme_companies = companies.search([("theme_id", "=", False)])
  15. menuitem_companies = companies.search([("menuitem_id", "=", False)])
  16. users = env["res.users"].search(
  17. domain + [("theme_id", "=", False), ("groups_id", "=", 1)]
  18. )
  19. for company in theme_companies:
  20. company.theme_id = (
  21. env["res.theme"].sudo()._get_or_create_theme(company.id, "company")
  22. )
  23. for company in menuitem_companies:
  24. company.menuitem_id = (
  25. env["res.user.menuitems"].sudo()._get_or_create_menuitems(company.id)
  26. )
  27. for user in users:
  28. user.theme_id = env["res.theme"].sudo()._get_or_create_theme(user.id, "user")
  29. companies.clear_caches()
上海开阖软件有限公司 沪ICP备12045867号-1