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

按照法人实体和入职日期字段写入不同薪资方案

XMLWord打印

    • B-宝石花-Y2021044
    • PRO
    • 基础通用功能
    • 隐藏
      location_mapping = {
          '101': '北京',
          '201': '西安',
          '301': '江苏',
          '501': '桂林',
          '601': '新疆',
      }
      # 配置这个前需要先在报表中心查询各个薪资方案的id,参考下面的sql
      # select * from hr_payroll_solution_view where status='published' and deleted_at is null
      solution_mapping = {
          '北京': 6,
          '西安': 10,
          '江苏': 9,
          '桂林': 11,
          '新疆': 3
      }
      # 查询员工
      employees = env['hr.employee'].search([('active', '=', True)])
      for employee in employees:
          payroll_solution = env['hr.payroll.solution'].search([('employee_id', '=', employee.id)])
          # 如果已有薪资方案,则跳过
          if payroll_solution:
              continue
          if not employee.job_info_id or employee.job_info_id.status == 'inactive' or not employee.job_info_id.legal_entity_id:
              continue
          area_code = employee.job_info_id.legal_entity_id.x_area_code or ''
          if not area_code:
              continue
          solution_id = solution_mapping.get(location_mapping.get(area_code, False), False)
          if solution_id:
              env['solution_id'].create({
                  'solution_id': solution_id,
                  'start_date': employee.hire_date
              })
      
      显示
      location_mapping = { '101' : '北京' , '201' : '西安' , '301' : '江苏' , '501' : '桂林' , '601' : '新疆' , } # 配置这个前需要先在报表中心查询各个薪资方案的id,参考下面的sql # select * from hr_payroll_solution_view where status= 'published' and deleted_at is null solution_mapping = { '北京' : 6, '西安' : 10, '江苏' : 9, '桂林' : 11, '新疆' : 3 } # 查询员工 employees = env[ 'hr.employee' ].search([( 'active' , '=' , True)]) for employee in employees: payroll_solution = env[ 'hr.payroll.solution' ].search([( 'employee_id' , '=' , employee.id)]) # 如果已有薪资方案,则跳过 if payroll_solution: continue if not employee.job_info_id or employee.job_info_id.status == 'inactive' or not employee.job_info_id.legal_entity_id: continue area_code = employee.job_info_id.legal_entity_id.x_area_code or '' if not area_code: continue solution_id = solution_mapping.get(location_mapping.get(area_code, False), False) if solution_id: env[ 'solution_id' ].create({ 'solution_id' : solution_id, 'start_date' : employee.hire_date })

      比如法人实体是新疆的,就把他写入新疆的薪资方案,有问题请联系我

        1. screenshot-1.png
          229 kB
          陈灵娟
        2. 问题01.png
          87 kB
          刘谨嘉
        3. 问题02.png
          65 kB
          刘谨嘉
        4. 问题03.png
          58 kB
          刘谨嘉

            ling.chen 陈灵娟
            neo.liu 刘谨嘉
            表决:
            0 为这个问题表决

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

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