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

17作业自动生成续签合同逻辑修改

XMLWord打印

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

      将原来定时任务代码调整为如下代码即可:

      run_time_since = (datetime.now() + relativedelta.relativedelta(days=45)).strftime('%Y-%m-%d')
      today = datetime.now().strftime('%Y-%m-%d')
      records = env['hr.contract'].search(cr, 1, [('active','=', True), ('date_end', '<=', run_time_since),('date_end', '>=', today), ('contract_status','=','current_contract'), ('contract_agreement_category', '=', 'labor_contract')])
      val_dict = {}
      if records:
      for record in records:
      pre_contract = env['hr.contract'].browse(cr, 1, record)
      pre_end = datetime.strptime(pre_contract.date_end,'%Y-%m-%d')
      begin_date = pre_end + relativedelta.relativedelta(days=1)
      end_date = begin_date + relativedelta.relativedelta(days=-1, years=3)
      days = (end_date - begin_date).days
      begin_date = begin_date.strftime('%Y-%m-%d')
      end_date = end_date.strftime('%Y-%m-%d')
      contract_type_record = env['hr.contract.category'].search(cr, 1, [('name','=', 'Fixed-term Labor Contract')])
      contract_type_id = contract_type_record[0] if contract_type_record else None
      working_hours = env['resource.calendar'].search(cr, 1, [('name', '=','Standard Working Hours')])[0]
      val_dict =

      { 'employee_id': pre_contract.employee_id.id, 'date_start': begin_date, 'date_end': end_date, 'trial_date_start': None, 'trial_date_end': None, 'contract_category_id': contract_type_id, 'legal_entity_id': pre_contract.legal_entity_id.id, 'probation_date': None, 'days': days, # 'template_id': pre_contract.template_id.id, 'contract_number': pre_contract.contract_number + 1 if pre_contract.contract_number else 1, 'contract_total_count': pre_contract.contract_total_count + 1 if pre_contract.contract_total_count else 1., 'duration': 3, 'working_hours': working_hours, 'lang_id': pre_contract.lang_id.id, 'contract_location': pre_contract.contract_location.id, 'renew': True, 'last_contract_start': pre_contract.date_start, 'last_contract_end':pre_contract.date_end, 'x_':pre_contract.x_ }

      contract = env['hr.contract'].search(cr, 1, [('employee_id', '=', pre_contract.employee_id.id), ('date_end', '=', end_date), ('contract_agreement_category', '=', 'labor_contract')])
      if not contract:
      contract_rec = env['hr.contract'].create(cr, 1, val_dict)

      显示
      将原来定时任务代码调整为如下代码即可: run_time_since = (datetime.now() + relativedelta.relativedelta(days=45)).strftime('%Y-%m-%d') today = datetime.now().strftime('%Y-%m-%d') records = env ['hr.contract'] .search(cr, 1, [('active','=', True), ('date_end', '<=', run_time_since),('date_end', '>=', today), ('contract_status','=','current_contract'), ('contract_agreement_category', '=', 'labor_contract')] ) val_dict = {} if records: for record in records: pre_contract = env ['hr.contract'] .browse(cr, 1, record) pre_end = datetime.strptime(pre_contract.date_end,'%Y-%m-%d') begin_date = pre_end + relativedelta.relativedelta(days=1) end_date = begin_date + relativedelta.relativedelta(days=-1, years=3) days = (end_date - begin_date).days begin_date = begin_date.strftime('%Y-%m-%d') end_date = end_date.strftime('%Y-%m-%d') contract_type_record = env ['hr.contract.category'] .search(cr, 1, [('name','=', 'Fixed-term Labor Contract')] ) contract_type_id = contract_type_record [0] if contract_type_record else None working_hours = env ['resource.calendar'] .search(cr, 1, [('name', '=','Standard Working Hours')] ) [0] val_dict = { 'employee_id': pre_contract.employee_id.id, 'date_start': begin_date, 'date_end': end_date, 'trial_date_start': None, 'trial_date_end': None, 'contract_category_id': contract_type_id, 'legal_entity_id': pre_contract.legal_entity_id.id, 'probation_date': None, 'days': days, # 'template_id': pre_contract.template_id.id, 'contract_number': pre_contract.contract_number + 1 if pre_contract.contract_number else 1, 'contract_total_count': pre_contract.contract_total_count + 1 if pre_contract.contract_total_count else 1., 'duration': 3, 'working_hours': working_hours, 'lang_id': pre_contract.lang_id.id, 'contract_location': pre_contract.contract_location.id, 'renew': True, 'last_contract_start': pre_contract.date_start, 'last_contract_end':pre_contract.date_end, 'x_':pre_contract.x_ } contract = env ['hr.contract'] .search(cr, 1, [('employee_id', '=', pre_contract.employee_id.id), ('date_end', '=', end_date), ('contract_agreement_category', '=', 'labor_contract')] ) if not contract: contract_rec = env ['hr.contract'] .create(cr, 1, val_dict)

      改为<=45天

            grant.yang 杨光磊
            zhongshm 钟时敏
            表决:
            0 为这个问题表决

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