中国本土应用
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.

33 lines
987B

  1. # -*- coding: utf-8 -*-
  2. from odoo import models, _
  3. from odoo.addons.oec_im_wecom_api.api.wecom_abstract_api import ApiException
  4. class User(models.Model):
  5. _inherit = ["res.users"]
  6. def get_wecom_openid(self):
  7. """
  8. 获取企微OpenID
  9. """
  10. for user in self:
  11. try:
  12. wxapi = self.env["wecom.service_api"].InitServiceApi(
  13. user.company_id.corpid, user.company_id.contacts_app_id.secret,
  14. )
  15. response = wxapi.httpCall(
  16. self.env["wecom.service_api_list"].get_server_api_call(
  17. "USERID_TO_OPENID"
  18. ),
  19. {"userid": user.wecom_userid,},
  20. )
  21. except ApiException as ex:
  22. self.env["wecomapi.tools.action"].ApiExceptionDialog(
  23. ex, raise_exception=True
  24. )
  25. else:
  26. user.wecom_openid = response["openid"]
上海开阖软件有限公司 沪ICP备12045867号-1