企业微信 通步

This commit is contained in:
pengyuthon
2024-06-30 20:56:32 +08:00
parent e50f908657
commit 9e92b1368e
4 changed files with 7 additions and 8 deletions
+1 -1
View File
@@ -101,6 +101,6 @@ class WeComApi(models.Model):
"""
wecom_api = self.search([('function', '=', function)], limit=1)
response = wecom_api.http_request_url(data, access_token)
response = json.loads(response)
response = json.loads(response.content)
return response
+2 -2
View File
@@ -35,8 +35,8 @@ class WeComApps(models.Model):
def sync_function_api(self, apps_type, api_function, data):
wecom_app = self.sudo().env["wecom.apps.config"].search([("wecom_apps_type", "=", apps_type)], limit=1).wecom_apps_id
result_data = self.sudo().env['wecom.api'].function_http_request(api_function, data, wecom_app.access_token)
if result_data.get("errcode", 0) in ["40014"]:
self.sync_access_token()
if result_data.get("errcode", 0) in [40014]:
wecom_app.sync_access_token()
wecom_app = self.sudo().env["wecom.apps.config"].search([("wecom_apps_type", "=", apps_type)],limit=1).wecom_apps_id
result_data = self.sudo().env['wecom.api'].function_http_request(api_function, data, wecom_app.access_token)
return result_data
+1 -1
View File
@@ -13,7 +13,7 @@ class WecomAppsConfig(models.Model):
wecom_apps_type = fields.Selection(
string='应用分类',
selection=[('default', '暂未启用功能'),
('USER_LIST', '通讯录同步应用'),
('USER_LIST', '员工同步应用'),
('DEPARTMENT_LIST', '部门同步应用'),
('login', '登录验证应用'),
('SEND_MESSAGE', '发送消息应用'),
@@ -28,8 +28,8 @@ class WeComApiSyncWizard(models.Model):
wecom_name_en = department.get("name_en", "")
wecom_department_leader = department.get("department_leader", "")
wecom_order = department.get("order", "")
wecom_parent_id = department.get("parent_id", 0)
hr_departments = self.sudo().env["hr.department"].with_context(active_test=False).search([("name", '=', name)])
wecom_parent_id = department.get("parentid", 0)
hr_departments = self.sudo().env["hr.department"].with_context(active_test=False).search([("wecom_id", '=', wecom_id)])
data = {
"name": name,
"wecom_id": wecom_id,
@@ -56,8 +56,7 @@ class WeComApiSyncWizard(models.Model):
# 开始按照部门逐步获取员工
hr_departments = self.sudo().env["hr.department"].search([("wecom_id", "!=", False)])
for hr_department in hr_departments:
wecom_departments = self.sudo().env["wecom.apps"].sync_department_list()
user_list = wecom_departments.sync_user_list(hr_department.wecom_id)
user_list = self.sudo().env["wecom.apps"].sync_user_list(hr_department.wecom_id)
for user in user_list:
biz_mail = user.get("biz_mail", "")
userid = user.get("userid", "")