添加功能

This commit is contained in:
zhouzhou
2024-11-27 10:55:55 +08:00
parent 8e921a1927
commit c7b67c228f
+80 -8
View File
@@ -22,14 +22,28 @@ class YuthonSalaryWizard(models.Model):
raise ValidationError('请上传文件。')
book = xlrd.open_workbook(file_contents=base64.decodebytes(self.excel_file))
sh = book.sheet_by_index(0)
salary_dates = []
salary_dates_tz = []
salary_dates_lc = []
salary_dates_wg = []
for rx in range(0, sh.nrows):
row = sh.row(rx)
if rx == 0:
if rx == 0 and sh.name == '天河投资':
for r in row[3:9]:
salary_dates.append(r)
salary_dates_tz.append(r)
elif rx == 0 and sh.name == '天河物管':
for r in row[3:15]:
salary_dates_lc.append(r)
elif rx == 0 and sh.name == '天河粮储':
for r in row[3:10]:
salary_dates_wg.append(r)
else:
self.salary_user_data(row,salary_dates)
if sh.name == '天河投资':
self.salary_tz_data(row,salary_dates_tz)
elif sh.name == '天河粮储':
self.salary_lc_data(row, salary_dates_lc)
elif sh.name == '天河物管':
self.salary_wg_data(row, salary_dates_wg)
return {
'name': '批量更新工资项',
'type': 'ir.actions.act_window',
@@ -37,16 +51,14 @@ class YuthonSalaryWizard(models.Model):
'res_model': 'hr.salary.rule',
}
def salary_user_data(self,row,salary_dates):
def salary_tz_data(self,row,salary_dates):
yuthon_company_dict = {'天河投资集团': 'thtz', '天河物管': 'thwg', '天河粮储': 'thlc', '': ''}
yuthon_company_dict2 = {'天河投资集团': 'TT', '天河物管': 'TW', '天河粮储': 'TL', '': ''}
salary_name = self.env['hr.salary.rule']
text = row[2].value
yuthon_company = yuthon_company_dict.get(row[10].value)
struct_id = self.env['hr.payroll.structure'].search([('name', '=', text)])
if struct_id:
pass
else:
if not struct_id:
struct_id = self.env['hr.payroll.structure'].create({
'name':text,
'lv':row[1].value,
@@ -65,4 +77,64 @@ class YuthonSalaryWizard(models.Model):
'yuthon_company': yuthon_company,
'amount_select' : 'fix',
}
salary_name.create(salary_date)
def salary_lc_data(self, row, salary_dates):
yuthon_company_dict = {'天河投资集团': 'thtz', '天河物管': 'thwg', '天河粮储': 'thlc', '': ''}
yuthon_company_dict2 = {'天河投资集团': 'TT', '天河物管': 'TW', '天河粮储': 'TL', '': ''}
salary_name = self.env['hr.salary.rule']
text = row[2].value
yuthon_company = yuthon_company_dict.get(row[11].value)
struct_id = self.env['hr.payroll.structure'].search([('name', '=', text)])
if struct_id:
pass
else:
struct_id = self.env['hr.payroll.structure'].create({
'name': text,
'lv': row[1].value,
'sequence': row[0].value,
'yuthon_company': yuthon_company})
yuthon_company = yuthon_company_dict.get(row[11].value)
yuthon_company2 = yuthon_company_dict2.get(row[11].value)
for salary in salary_dates:
name_pinyin = pinyin(salary.value, style=Style.FIRST_LETTER)
abbreviation = "".join([p[0][0] for p in name_pinyin]).upper()
salary_date = {
'sequence': row[0].value,
'code': yuthon_company2 + abbreviation,
'name': salary.value, # 姓名
'struct_id': struct_id.id,
'yuthon_company': yuthon_company,
'amount_select': 'fix',
}
salary_name.create(salary_date)
def salary_wg_data(self, row, salary_dates):
yuthon_company_dict = {'天河投资集团': 'thtz', '天河物管': 'thwg', '天河粮储': 'thlc', '': ''}
yuthon_company_dict2 = {'天河投资集团': 'TT', '天河物管': 'TW', '天河粮储': 'TL', '': ''}
salary_name = self.env['hr.salary.rule']
text = row[2].value
yuthon_company = yuthon_company_dict.get(row[16].value)
struct_id = self.env['hr.payroll.structure'].search([('name', '=', text)])
if struct_id:
pass
else:
struct_id = self.env['hr.payroll.structure'].create({
'name': text,
'lv': row[1].value,
'sequence': row[0].value,
'yuthon_company': yuthon_company})
yuthon_company = yuthon_company_dict.get(row[16].value)
yuthon_company2 = yuthon_company_dict2.get(row[16].value)
for salary in salary_dates:
name_pinyin = pinyin(salary.value, style=Style.FIRST_LETTER)
abbreviation = "".join([p[0][0] for p in name_pinyin]).upper()
salary_date = {
'sequence': row[0].value,
'code': yuthon_company2 + abbreviation,
'name': salary.value, # 姓名
'struct_id': struct_id.id,
'yuthon_company': yuthon_company,
'amount_select': 'fix',
}
salary_name.create(salary_date)