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

【阿缇希】年假的有效期需要从3月1日开始至次年2月28or29日

XMLWord打印

    • A-阿缇希-Y2021037
    • PRO
    • 阿缇希生产站
    • 基础通用功能
    • 隐藏
      employee = env['hr.employee'].search([('id','=',employee_id), ('active','=', True), ('is_probation','=', False)])
      hire_date = employee.hire_date
      year_now = datetime.datetime.today().year
      today = datetime.datetime.today()
      date_str = '%s-03-01' %year_now
      date_flag = datetime.datetime.strptime(date_str, '%Y-%m-%d')
      
      if today < date_flag:
        year_now -= 1
      date_str = '%s-03-01' %year_now
      date_flag = datetime.datetime.strptime(date_str, '%Y-%m-%d')
      diff = relativedelta.relativedelta(date_flag, hire_date)
      leave_res = 0
      if diff.years<1:
        leave_res=0
      if  1<= diff.years  <= 2:
        leave_res = 10
      elif 2< diff.years <= 5:
        leave_res = 13
      if 5 < diff.years <= 7:
        leave_res = 15
      if 7 < diff.years <= 10:
        leave_res = 17
      if diff.years >= 11:
        leave_res = 20
      
      period = env['hr.holiday.period'].search([('id','=',period_id)])
      period_year = period.name
      
      def last_day_of_month(any_day):
        next_month = any_day.replace(day=28) + datetime.timedelta(days=4)
        return next_month - datetime.timedelta(days=next_month.day)
      
      def first_day_of_month(month_str):
        date_str = "%s-%s-01" % (period_year,month_str)
        return (datetime.datetime.strptime(date_str, "%Y-%m-%d")).date()
      
      frequency = rule.get('frequency')
      if frequency == 'month':
        result = [
        {'result': 0, 'start_date': first_day_of_month("01"), 'end_date': last_day_of_month(first_day_of_month("12"))},
        {'result': 0, 'start_date': first_day_of_month("02"), 'end_date': last_day_of_month(first_day_of_month("12"))},
        {'result': leave_res*8, 'start_date': first_day_of_month("03"), 'end_date': last_day_of_month(first_day_of_month("12"))},
        {'result': 0, 'start_date': first_day_of_month("04"), 'end_date': last_day_of_month(first_day_of_month("12"))},
        {'result': 0, 'start_date': first_day_of_month("05"), 'end_date': last_day_of_month(first_day_of_month("12"))},
        {'result': 0, 'start_date': first_day_of_month("06"), 'end_date': last_day_of_month(first_day_of_month("12"))},
        {'result': 0, 'start_date': first_day_of_month("07"), 'end_date': last_day_of_month(first_day_of_month("12"))},
        {'result': 0, 'start_date': first_day_of_month("08"), 'end_date': last_day_of_month(first_day_of_month("12"))},
        {'result': 0, 'start_date': first_day_of_month("09"), 'end_date': last_day_of_month(first_day_of_month("12"))},
        {'result': 0, 'start_date': first_day_of_month("10"), 'end_date': last_day_of_month(first_day_of_month("12"))},
        {'result': 0, 'start_date': first_day_of_month("11"), 'end_date': last_day_of_month(first_day_of_month("12"))},
        {'result': 0, 'start_date': first_day_of_month("12"), 'end_date': last_day_of_month(first_day_of_month("12"))}
        ]      
      else:
        result = []
      
      显示
      employee = env[ 'hr.employee' ].search([( 'id' , '=' ,employee_id), ( 'active' , '=' , True), ( 'is_probation' , '=' , False)]) hire_date = employee.hire_date year_now = datetime.datetime.today().year today = datetime.datetime.today() date_str = '%s-03-01' %year_now date_flag = datetime.datetime.strptime(date_str, '%Y-%m-%d' ) if today < date_flag: year_now -= 1 date_str = '%s-03-01' %year_now date_flag = datetime.datetime.strptime(date_str, '%Y-%m-%d' ) diff = relativedelta.relativedelta(date_flag, hire_date) leave_res = 0 if diff.years<1: leave_res=0 if 1<= diff.years <= 2: leave_res = 10 elif 2< diff.years <= 5: leave_res = 13 if 5 < diff.years <= 7: leave_res = 15 if 7 < diff.years <= 10: leave_res = 17 if diff.years >= 11: leave_res = 20 period = env[ 'hr.holiday.period' ].search([( 'id' , '=' ,period_id)]) period_year = period.name def last_day_of_month(any_day): next_month = any_day.replace(day=28) + datetime.timedelta(days=4) return next_month - datetime.timedelta(days=next_month.day) def first_day_of_month(month_str): date_str = "%s-%s-01" % (period_year,month_str) return (datetime.datetime.strptime(date_str, "%Y-%m-%d" )).date() frequency = rule.get( 'frequency' ) if frequency == 'month' : result = [ { 'result' : 0, 'start_date' : first_day_of_month( "01" ), 'end_date' : last_day_of_month(first_day_of_month( "12" ))}, { 'result' : 0, 'start_date' : first_day_of_month( "02" ), 'end_date' : last_day_of_month(first_day_of_month( "12" ))}, { 'result' : leave_res*8, 'start_date' : first_day_of_month( "03" ), 'end_date' : last_day_of_month(first_day_of_month( "12" ))}, { 'result' : 0, 'start_date' : first_day_of_month( "04" ), 'end_date' : last_day_of_month(first_day_of_month( "12" ))}, { 'result' : 0, 'start_date' : first_day_of_month( "05" ), 'end_date' : last_day_of_month(first_day_of_month( "12" ))}, { 'result' : 0, 'start_date' : first_day_of_month( "06" ), 'end_date' : last_day_of_month(first_day_of_month( "12" ))}, { 'result' : 0, 'start_date' : first_day_of_month( "07" ), 'end_date' : last_day_of_month(first_day_of_month( "12" ))}, { 'result' : 0, 'start_date' : first_day_of_month( "08" ), 'end_date' : last_day_of_month(first_day_of_month( "12" ))}, { 'result' : 0, 'start_date' : first_day_of_month( "09" ), 'end_date' : last_day_of_month(first_day_of_month( "12" ))}, { 'result' : 0, 'start_date' : first_day_of_month( "10" ), 'end_date' : last_day_of_month(first_day_of_month( "12" ))}, { 'result' : 0, 'start_date' : first_day_of_month( "11" ), 'end_date' : last_day_of_month(first_day_of_month( "12" ))}, { 'result' : 0, 'start_date' : first_day_of_month( "12" ), 'end_date' : last_day_of_month(first_day_of_month( "12" ))} ] else : result = []

      【阿缇希】年假的有效期需要从3月1日开始至次年2月28or29日

            grant.yang 杨光磊
            amy.he 贺晨晨
            表决:
            0 为这个问题表决

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

                预估时间:
                初始预估 - 尚未指定
                尚未指定
                剩余:
                剩余的估算 - 0小时
                0小时
                实际工作时间:
                耗费时间 - 2小时
                2小时