27 lines
963 B
Python
27 lines
963 B
Python
import logging
|
|
import requests
|
|
from odoo import models, fields, api, _
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class JkmPracticeEmployee(models.Model):
|
|
_inherit = 'hr.employee'
|
|
_description = '员工信息'
|
|
|
|
we_id = fields.Char(string='企微ID', index=True)
|
|
|
|
def _employee_info_sync(self):
|
|
url = '/api/get/organization'
|
|
config = self.env['res.config.settings'].get_values()
|
|
ret = requests.post((config['ims_url'] + url), json={}, data={})
|
|
result = ret.json()['result']
|
|
if result['code'] == 200:
|
|
if result['employee_list']:
|
|
for employee_info in result['employee_list']:
|
|
if employee_info['work_email']:
|
|
self.sudo().search([('work_email', '=', employee_info['work_email'])]).write(
|
|
{'we_id': employee_info['we_id']})
|
|
else:
|
|
logging.info('_employee_info_sync error:%s' % result['message'])
|