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

【Pro-中信】人事提醒-合同到期,试用期转正提醒触发条件

XMLWord打印

    • Icon: 任务 任务
    • 解决结果: 完成
    • Icon: High High
    • 202104
    • F-FA-中信银行-Y2020075
    • 中信UAT环境, trustlinktest
    • 人力资源等
    • 隐藏

      合同到期(R135;Expired Contract For TrustLink):

      emp_active_status_id = self.env.ref('employee_central.employee_status_active').id  # 员工在职状态ID
      today = datetime.date.today()
      reminder_day = today + datetime.timedelta(days=self.reminder_advance_days)
      # 1. 查询到期的合同
      domain = [
          ('employee_id.employee_status', '=', emp_active_status_id),
          ('contract_date_end', '=', reminder_day),
          ('contract_agreement_id.category', '=', 'contract'),
          ('contract_agreement_status', '=', 'current_contract'),
      ]
      
      instances = self.env['bp'].query_done(self.env['hr.contract'], domain=domain)
      if instances:
          # 2. 查找续签的(同一法人实体&同一合同类型)
          employees = instances.mapped('employee_id')
          domain = [
              ('contract_agreement_id.category', '=', 'contract'),
              ('employee_id', 'in', employees.ids),
              ('contract_date_end', '>', reminder_day)
          ]
          # 所有新合同(提交了审批的)
          renew = self.env['bp'].query_status(instances, BP_SUBMIT_STATUS, domain)
          for instance in instances:
              instances = instances - renew.filtered(lambda x: x.legal_entity_id == instance.legal_entity_id)
      
          if instances:
              # 3. 查找离职日期大于合同到期日期的审批通过的
              employees = instances.mapped('employee_id')
              registination_employees = set(employees.filtered(
                  lambda emp: emp.termination_date and emp.termination_date <= reminder_day and emp.job_info_id.job_sequence_id.code == "SQ001").ids)
              instances = [instance for instance in instances if instance.employee_id.id not in registination_employees]
      
      result = {
          'instances': instances,
          'business_type': 'contract'
      }
      

      转正(R137 ;Positive Reminder For TrustLink):

      today = datetime.date.today()
      reminder_day = today + datetime.timedelta(days=self.reminder_advance_days)
      # 1. 查询转正的员工
      emp_active_status_id = self.env.ref('employee_central.employee_status_active').id  # 员工在职状态ID
      
      instances = self.env['hr.employee'].search([
          ('probation_date', '=', reminder_day),
          ('employee_status', '=', emp_active_status_id)
      ])
      if instances:
          # 2. 查找已经提交转正申请的
          domain = [
              ('employee_id', 'in', instances.ids)
          ]
          probations = self.env['bp'].query_status(self.env['employee.probation'], BP_SUBMIT_STATUS, domain)
          instances = instances - probations.mapped('employee_id')
          if instances:
              # 3. 查找提交离职的
              instances = instances - instances.filtered(
                  lambda emp: emp.termination_date and emp.termination_date <= reminder_day and emp.job_info_id.job_sequence_id.code == "SQ001")
      
      result = {'instances': instances, 'business_type': 'probation'}
      
      显示
      合同到期(R135;Expired Contract For TrustLink): emp_active_status_id = self.env.ref( 'employee_central.employee_status_active' ).id # 员工在职状态ID today = datetime.date.today() reminder_day = today + datetime.timedelta(days=self.reminder_advance_days) # 1. 查询到期的合同 domain = [ ( 'employee_id.employee_status' , '=' , emp_active_status_id), ( 'contract_date_end' , '=' , reminder_day), ( 'contract_agreement_id.category' , '=' , 'contract' ), ( 'contract_agreement_status' , '=' , 'current_contract' ), ] instances = self.env[ 'bp' ].query_done(self.env[ 'hr.contract' ], domain=domain) if instances: # 2. 查找续签的(同一法人实体&同一合同类型) employees = instances.mapped( 'employee_id' ) domain = [ ( 'contract_agreement_id.category' , '=' , 'contract' ), ( 'employee_id' , 'in' , employees.ids), ( 'contract_date_end' , '>' , reminder_day) ] # 所有新合同(提交了审批的) renew = self.env[ 'bp' ].query_status(instances, BP_SUBMIT_STATUS, domain) for instance in instances: instances = instances - renew.filtered(lambda x: x.legal_entity_id == instance.legal_entity_id) if instances: # 3. 查找离职日期大于合同到期日期的审批通过的 employees = instances.mapped( 'employee_id' ) registination_employees = set(employees.filtered( lambda emp: emp.termination_date and emp.termination_date <= reminder_day and emp.job_info_id.job_sequence_id.code == "SQ001" ).ids) instances = [instance for instance in instances if instance.employee_id.id not in registination_employees] result = { 'instances' : instances, 'business_type' : 'contract' } 转正(R137 ;Positive Reminder For TrustLink): today = datetime.date.today() reminder_day = today + datetime.timedelta(days=self.reminder_advance_days) # 1. 查询转正的员工 emp_active_status_id = self.env.ref( 'employee_central.employee_status_active' ).id # 员工在职状态ID instances = self.env[ 'hr.employee' ].search([ ( 'probation_date' , '=' , reminder_day), ( 'employee_status' , '=' , emp_active_status_id) ]) if instances: # 2. 查找已经提交转正申请的 domain = [ ( 'employee_id' , 'in' , instances.ids) ] probations = self.env[ 'bp' ].query_status(self.env[ 'employee.probation' ], BP_SUBMIT_STATUS, domain) instances = instances - probations.mapped( 'employee_id' ) if instances: # 3. 查找提交离职的 instances = instances - instances.filtered( lambda emp: emp.termination_date and emp.termination_date <= reminder_day and emp.job_info_id.job_sequence_id.code == "SQ001" ) result = { 'instances' : instances, 'business_type' : 'probation' }

      人事提醒-合同到期,试用期转正 需要增加触发条件:
      员工.雇佣信息.职务序列 code = SQ001

            chengdd 程丹丹
            yu.yu 俞晶晶
            表决:
            0 为这个问题表决

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