中国本土应用
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.
彩虹工作室 79d7b357c2 [ADD]添加素材模块 1 year ago
..
api 添加企业微信基础模块 1 year ago
controllers 添加企业微信基础模块 1 year ago
data 添加企业微信基础模块 1 year ago
i18n 添加企业微信基础模块 1 year ago
models 添加企业微信基础模块 1 year ago
security 添加企业微信基础模块 1 year ago
static 添加企业微信基础模块 1 year ago
tools [ADD]添加素材模块 1 year ago
views [ADD]添加oec_im_wecom_contacts模块 1 year ago
__init__.py 添加企业微信基础模块 1 year ago
__manifest__.py 添加企业微信基础模块 1 year ago
readme.md 添加企业微信基础模块 1 year ago

readme.md

如何使用封装好的企业微信 API

Demo:获取企业微信部门列表

# 初始化API 模型对象
# 参数为:公司对象,secret字段的名称,以及令牌类型
wxapi = self.env["wecom.service_api"].InitServiceApi(
    company, "contacts_secret", "contacts"
)

# "DEPARTMENT_LIST"是请求的API类型,通过API类型生成 调用企业微信的API URL
response = wxapi.httpCall(
    self.env["wecom.service_api_list"].get_server_api_call(
        "DEPARTMENT_LIST"
    ),
    {
        "id": str(company.contacts_sync_hr_department_id),
    },
)

建议:调用 API 的时候,尽量使用 try except 抛出异常的方式

from odoo.addons.oec_im_wecom_api.api.wecom_abstract_api import ApiException


try:
    ....
    ....
    ....
except ApiException as e:
    # 弹框显示异常
    return self.env["wecom.tools"].ApiExceptionDialog(ex)
上海开阖软件有限公司 沪ICP备12045867号-1