From c7b67c228fcdfe559c2a54dd0fe4f890fdb07acb Mon Sep 17 00:00:00 2001 From: zhouzhou <123@qq.com> Date: Wed, 27 Nov 2024 10:55:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_salary/wizard/yuthon_salary_wizard.py | 88 ++++++++++++++++++-- 1 file changed, 80 insertions(+), 8 deletions(-) diff --git a/yuthon_salary/wizard/yuthon_salary_wizard.py b/yuthon_salary/wizard/yuthon_salary_wizard.py index 79263fa57..f6eb45197 100644 --- a/yuthon_salary/wizard/yuthon_salary_wizard.py +++ b/yuthon_salary/wizard/yuthon_salary_wizard.py @@ -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) \ No newline at end of file