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

Pro-周年提醒作用范围python code编写

XMLWord打印

    • Icon: 任务 任务
    • 解决结果: 完成
    • Icon: High High
    • 202101
    • Y-易路产品-
    • OYOTEST,UAT环境
    • 人力资源等
    • 隐藏

      触发条件处为第一层筛选条件,更改对应relativedelta的years的值可以实现不同年限:
      today = datetime.date.today()
      reminder_day = today + datetime.timedelta(days=self.reminder_advance_days)
      filter_day = (reminder_day-dateutil.relativedelta.relativedelta(years=1)).strftime('%Y-%m-%d')
      employees = env['hr.employee'].search([('active','=', True),('employee_status.code','=','active'),('hire_date','=',filter_day)])
      result =

      {'instances': employees}

      而作用范围是第二层筛选条件,如果配置了作用范围,则筛选条件和作用范围两个条件中都有的员工才会被发送提醒:
      ids = []
      result = []
      today = datetime.date.today()
      reminder_day = today + datetime.timedelta(days=self.reminder_advance_days)
      filter_day = (reminder_day-dateutil.relativedelta.relativedelta(years=1)).strftime('%Y-%m-%d')
      employees = env['hr.employee'].search([('active','=', True),('employee_status.code','=','active'),('hire_date','=',filter_day)])
      for employee in employees:
      ids.append(employee.user_id.id)
      if len(ids)>1:
      result = env['res.users'].search([('id','in',ids)])
      elif len(ids)==1:
      result = env['res.users'].search([('id','=',ids[0])])

      显示
      触发条件处为第一层筛选条件,更改对应relativedelta的years的值可以实现不同年限: today = datetime.date.today() reminder_day = today + datetime.timedelta(days=self.reminder_advance_days) filter_day = (reminder_day-dateutil.relativedelta.relativedelta(years=1)).strftime('%Y-%m-%d') employees = env ['hr.employee'] .search( [('active','=', True),('employee_status.code','=','active'),('hire_date','=',filter_day)] ) result = {'instances': employees} 而作用范围是第二层筛选条件,如果配置了作用范围,则筛选条件和作用范围两个条件中都有的员工才会被发送提醒: ids = [] result = [] today = datetime.date.today() reminder_day = today + datetime.timedelta(days=self.reminder_advance_days) filter_day = (reminder_day-dateutil.relativedelta.relativedelta(years=1)).strftime('%Y-%m-%d') employees = env ['hr.employee'] .search( [('active','=', True),('employee_status.code','=','active'),('hire_date','=',filter_day)] ) for employee in employees: ids.append(employee.user_id.id) if len(ids)>1: result = env ['res.users'] .search( [('id','in',ids)] ) elif len(ids)==1: result = env ['res.users'] .search([('id','=',ids [0] )])

      后台-设置-人力管理-人事提醒, 周年提醒
      作用范围code 逻辑:
      1. 今天+提前提醒天数 到 入职日期, >=1年且<2年的人
      2. 今天+提前提醒天数 到 入职日期, >=2年且<3年的人
      3. 今天+提前提醒天数 到 入职日期, >=3年的人

            grant.yang 杨光磊
            yu.yu 俞晶晶
            表决:
            0 为这个问题表决

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