添加功能

This commit is contained in:
李鹏宇
2025-12-22 15:34:09 +08:00
parent 93b33ad6f0
commit 3feff65025
4 changed files with 42 additions and 36 deletions
+1 -1
View File
@@ -726,7 +726,7 @@ class HolidaysRequestBatch(models.Model):
@api.depends('users_id')
def _compute_holiday_allowance(self):
current_date = fields.Date.today()
vacation_date = current_date - relativedelta(months=1)
vacation_date = current_date
for record in self:
reports_id = self.env['yuthon.vacation.reports'].search([('employee_id', '=', record.users_id.employee_ids.id),
('vacation_date', '=', vacation_date.replace(day=1))
@@ -173,16 +173,15 @@ class HrPayrollStructure(models.Model):
def salary_rule_data(self):
# 定义不同公司的字段映射
company_mappings = {
'天河物管': { # 天河物管
# '天河物管': {
# '基本工资': 'base_salary',
# '岗位工资': 'position_salary',
# '综合补贴': 'integrated_subsidy',
# '通讯补贴': 'communication_subsidy'
# },
'天河粮储': {
'基本工资': 'base_salary',
'岗位工资': 'position_salary',
'综合补贴': 'integrated_subsidy',
'通讯补贴': 'communication_subsidy'
},
'天河粮储': { # 天河梁储
'基本工资': 'base_salary',
'岗位工资': 'position_salary',
'岗位补贴': 'position_subsidy',
'职级工资': 'rank_salary',
'预发绩效奖金': 'advance_performance_bonuses'
}
}
@@ -21,7 +21,7 @@
<button name="open_record" type="object" class="btn btn-primary" string="查看详情"/>
</xpath>
<xpath expr="//field[@name='name']" position="before">
<field name="sequence"/>
<field name="sequence" column_invisible="1"/>
<field name="company_id" required="1" optional="hide"/>
<field name="type_id"/>
<field name="level_id" column_invisible="1"/>
@@ -46,6 +46,7 @@
<field name="model">hr.payroll.structure</field>
<field name="arch" type="xml">
<tree string="历史职级">
<field name="name"/>
<field name="base_salary"/>
<field name="rank_salary" groups="yuthon_salary.group_jtbb_user"/>
<field name="position_subsidy" groups="yuthon_salary.group_lc_user"/>
@@ -133,6 +134,7 @@
<field name="view_mode">tree,form,search</field>
<field name="domain">[('is_enable', '=', True)]</field>
<field name="context">{'search_default_is_enable':1}</field>
<field name="view_id" ref="hr_payroll_structure_inherit"/>
</record>
<record id="action_view_hr_payroll_structure_list_form1" model="ir.actions.act_window">
<field name="name">历史职级</field>
@@ -205,7 +207,7 @@
<field name="state">code</field>
<field name="code">action = model.onetime()</field>
</record>
<record id="all_data_write_salary" model="ir.actions.server">
<record id="all_data_write_salary1" model="ir.actions.server">
<field name="name">批量导入职级</field>
<field name="model_id" ref="hr_payroll.model_hr_payroll_structure"/>
<field name="binding_model_id" ref="hr_payroll.model_hr_payroll_structure"/>
+29 -24
View File
@@ -22,27 +22,31 @@ 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_tz = []
salary_dates_lc = []
salary_dates_wg = []
for rx in range(0, sh.nrows):
for rx in range(1, sh.nrows):
row = sh.row(rx)
if rx == 0 and sh.name == '天河投资':
for r in row[3:9]:
salary_dates_tz.append(r)
elif rx == 0 and sh.name == '天河物管':
for r in row[3:15]:
salary_dates_wg.append(r)
elif rx == 0 and sh.name == '天河粮储':
for r in row[3:10]:
salary_dates_lc.append(r)
else:
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)
self.salary_lc_data(row)
# sh = book.sheet_by_index(0)
# salary_dates_tz = []
# salary_dates_lc = []
# salary_dates_wg = []
# for rx in range(0, sh.nrows):
# row = sh.row(rx)
# if rx == 0 and sh.name == '天河投资':
# for r in row[3:9]:
# salary_dates_tz.append(r)
# elif rx == 0 and sh.name == '天河物管':
# for r in row[3:15]:
# salary_dates_wg.append(r)
# elif rx == 0 and sh.name == '天河粮储':
# for r in row[3:10]:
# salary_dates_lc.append(r)
# else:
# 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': '批量更新工资项',
@@ -114,7 +118,7 @@ class YuthonSalaryWizard(models.Model):
# }
# salary_name.create(salary_date)
def salary_lc_data(self, row, rx):
def salary_lc_data(self, row):
text = row[0].value
company_id = self.env['res.company'].search([('name', '=', '天河粮储')], limit=1)
level_id = self.env['yuthon.payroll.type.setting'].search([('name', '=', row[4].value),
@@ -122,24 +126,25 @@ class YuthonSalaryWizard(models.Model):
])
if not level_id:
level_id = self.env['yuthon.payroll.type.setting'].create({
'sequence': rx,
'sequence': row[5].value,
'name': row[4].value,
'company_id': company_id.id,
})
struct_id = self.env['hr.payroll.structure.type'].search([
('name', '=', text),
('company_id', '=', company_id.id)
])
if not struct_id:
struct_id = self.env['hr.payroll.structure.type'].create({
'name': text,
'sequence': rx})
'sequence': row[5].value})
self.env['hr.payroll.structure'].create({
'name': text,
'type_id': struct_id.id,
'level_id': level_id.id,
'company_id': company_id.id,
'create_time': datetime(2025, 11, 1).date(),
'sequence': rx, })
'sequence': row[5].value, })
def salary_wg_data(self, row, salary_dates):
salary_name = self.env['hr.salary.rule']