上传的图像用于项目: 'CST技术支持'
  1. CST技术支持
  2. SLAL2-1456

PRO写定时任务取部门管理岗上的员工作为部门负责人

XMLWord打印

    • Icon: Change Change
    • 解决结果: 完成
    • Icon: Medium Medium
    • 202012
    • Y-易路产品-
    • 基础通用功能
    • 隐藏

      代码如下:
      department_recs = env['hr.department'].search([])
      today = datetime.date.today()
      for department_rec in department_recs:
      x_bmglg = department_rec.x_bmglg

      employees = env['hr.employee'].search([('position_id', '=', x_bmglg.id)])
      employee_list = []
      parttimes = env['parttime.position'].search([('position_id', '=', x_bmglg.id)])
      for employee in employees:
      employee_list.append(employee)
      for parttime in parttimes:
      if parttime.end_date:
      if parttime.start_date >= today and parttime.end_date <= today:
      employee_list.append(parttime.employee_id)
      else:
      if parttime.start_date >= today:
      employee_list.append(parttime.employee_id)
      if len(employee_list) > 1 or len(employee_list) == 0:
      continue
      else:
      for employee in employee_list:
      if department_rec.manager_id.id != employee.id:
      department_rec.update(

      {'manager_id': employee.id}

      )

      显示
      代码如下: department_recs = env ['hr.department'] .search([]) today = datetime.date.today() for department_rec in department_recs: x_bmglg = department_rec.x_bmglg employees = env ['hr.employee'] .search( [('position_id', '=', x_bmglg.id)] ) employee_list = [] parttimes = env ['parttime.position'] .search( [('position_id', '=', x_bmglg.id)] ) for employee in employees: employee_list.append(employee) for parttime in parttimes: if parttime.end_date: if parttime.start_date >= today and parttime.end_date <= today: employee_list.append(parttime.employee_id) else: if parttime.start_date >= today: employee_list.append(parttime.employee_id) if len(employee_list) > 1 or len(employee_list) == 0: continue else: for employee in employee_list: if department_rec.manager_id.id != employee.id: department_rec.update( {'manager_id': employee.id} )

      部门上有【负责人】字段和【部门管理岗】字段,需要写定时任务取该部门【部门管理岗】上的员工作为该部门负责人

      注:
      1、客户存在兼岗情况,在查找部门管理岗上员工时需要考虑兼岗信息
      2、已跟客户确认每个部门管理岗为1岗1人,若找到多人的情况,该部门负责人为空
      3、该定时任务每天执行一次,若有人员调动也可触发该定时任务

            grant.yang 杨光磊
            zhangpp 张萍萍
            表决:
            0 为这个问题表决

              创建日期:
              已更新:
              已解决: