添加功能
This commit is contained in:
@@ -44,7 +44,7 @@ class YuthonDutyArrangement(models.Model):
|
||||
for record in self:
|
||||
if record.start_time:
|
||||
weekday = record.start_time.weekday()
|
||||
record.is_weekend = weekday in (5, 6) # 5 和 6 分别代表周六和周日
|
||||
record.is_weekend = weekday in (5, 6)
|
||||
else:
|
||||
record.is_weekend = False
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ class YuthonDutyPlan(models.Model):
|
||||
is_enable = fields.Boolean(string="启用", default=True)
|
||||
plan_line_ids = fields.One2many('duty.plan.line', 'duty_plan_id', string='关联计划明细')
|
||||
|
||||
|
||||
class DutyPlanLine(models.Model):
|
||||
_name = 'duty.plan.line'
|
||||
_description = '值班计划明细行'
|
||||
|
||||
@@ -55,10 +55,31 @@
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
<record id="hr_payroll.action_view_hr_payroll_structure_list_form" model="ir.actions.act_window">
|
||||
<field name="name">薪资管理</field>
|
||||
<record id="action_view_hr_payroll_structure_list_form" model="ir.actions.act_window">
|
||||
<field name="name">全部</field>
|
||||
<field name="res_model">hr.payroll.structure</field>
|
||||
<field name="view_mode">tree,form,search</field>
|
||||
<field name="context">{'search_default_group_lv': 1}</field>
|
||||
</record>
|
||||
<record id="action_view_hr_payroll_structure_list_form1" model="ir.actions.act_window">
|
||||
<field name="name">天河投资</field>
|
||||
<field name="res_model">hr.payroll.structure</field>
|
||||
<field name="view_mode">tree,form,search</field>
|
||||
<field name="context">{'search_default_group_lv': 1}</field>
|
||||
<field name="domain">[('yuthon_company', '=' , 'thtz')]</field>
|
||||
</record>
|
||||
<record id="action_view_hr_payroll_structure_list_form2" model="ir.actions.act_window">
|
||||
<field name="name">天河粮储</field>
|
||||
<field name="res_model">hr.payroll.structure</field>
|
||||
<field name="view_mode">tree,form,search</field>
|
||||
<field name="context">{'search_default_group_lv': 1}</field>
|
||||
<field name="domain">[('yuthon_company', '=', 'thlc')]</field>
|
||||
</record>
|
||||
<record id="action_view_hr_payroll_structure_list_form3" model="ir.actions.act_window">
|
||||
<field name="name">天河物管</field>
|
||||
<field name="res_model">hr.payroll.structure</field>
|
||||
<field name="view_mode">tree,form,search</field>
|
||||
<field name="context">{'search_default_group_lv': 1}</field>
|
||||
<field name="domain">[('yuthon_company', '=', 'thwg')]</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -16,6 +16,7 @@
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='code']" position="after">
|
||||
<field name="yuthon_company"/>
|
||||
<field name="amount_select"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
@@ -30,6 +31,34 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<record id="action_salary_rule_form" model="ir.actions.act_window">
|
||||
<field name="name">全部</field>
|
||||
<field name="res_model">hr.salary.rule</field>
|
||||
<field name="view_mode">tree,kanban,form</field>
|
||||
<field name="context">{'search_default_group_by_struct_id': 1}</field>
|
||||
</record>
|
||||
<record id="action_salary_rule_form1" model="ir.actions.act_window">
|
||||
<field name="name">天河投资</field>
|
||||
<field name="res_model">hr.salary.rule</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{'search_default_group_by_struct_id': 1}</field>
|
||||
<field name="domain">[('yuthon_company','=','thtz')]</field>
|
||||
</record>
|
||||
<record id="action_salary_rule_form2" model="ir.actions.act_window">
|
||||
<field name="name">天河粮储</field>
|
||||
<field name="res_model">hr.salary.rule</field>
|
||||
<field name="view_mode">tree,kanban,form</field>
|
||||
<field name="context">{'search_default_group_by_struct_id': 1}</field>
|
||||
<field name="domain">[('yuthon_company','=','thlc')]</field>
|
||||
</record>
|
||||
<record id="action_salary_rule_form3" model="ir.actions.act_window">
|
||||
<field name="name">天河物管</field>
|
||||
<field name="res_model">hr.salary.rule</field>
|
||||
<field name="view_mode">tree,kanban,form</field>
|
||||
<field name="context">{'search_default_group_by_struct_id': 1}</field>
|
||||
<field name="domain">[('yuthon_company','=','thwg')]</field>
|
||||
</record>
|
||||
|
||||
<record id="all_data_write_salary" model="ir.actions.server">
|
||||
<field name="name">批量导入职级</field>
|
||||
<field name="model_id" ref="hr_payroll.model_hr_salary_rule"/>
|
||||
|
||||
@@ -22,9 +22,14 @@ class YuthonSalaryWizard(models.Model):
|
||||
raise ValidationError('请上传文件。')
|
||||
book = xlrd.open_workbook(file_contents=base64.decodebytes(self.excel_file))
|
||||
sh = book.sheet_by_index(0)
|
||||
for rx in range(1, sh.nrows):
|
||||
salary_dates = []
|
||||
for rx in range(0, sh.nrows):
|
||||
row = sh.row(rx)
|
||||
self.salary_user_data(row)
|
||||
if rx == 0:
|
||||
for r in row[3:9]:
|
||||
salary_dates.append(r)
|
||||
else:
|
||||
self.salary_user_data(row,salary_dates)
|
||||
return {
|
||||
'name': '批量更新工资项',
|
||||
'type': 'ir.actions.act_window',
|
||||
@@ -32,22 +37,32 @@ class YuthonSalaryWizard(models.Model):
|
||||
'res_model': 'hr.salary.rule',
|
||||
}
|
||||
|
||||
def salary_user_data(self,row):
|
||||
name_pinyin = pinyin(row[1].value, style=Style.FIRST_LETTER)
|
||||
abbreviation = "".join([p[0][0] for p in name_pinyin]).upper()
|
||||
salary_name = self.env['hr.salary.rule'].search([('name', '=', row[1].value)])
|
||||
text = row[2].value
|
||||
struct_id = self.env['hr.payroll.structure'].search([('name', '=', text)])
|
||||
def salary_user_data(self,row,salary_dates):
|
||||
yuthon_company_dict = {'天河投资集团': 'thtz', '天河物管': 'thwg', '天河粮储': 'thlc', '': ''}
|
||||
yuthon_company_dict2 = {'天河投资集团': 'TT', '天河物管': 'TW', '天河粮储': 'TL', '': ''}
|
||||
yuthon_company = yuthon_company_dict.get(row[3].value)
|
||||
yuthon_company2 = yuthon_company_dict2.get(row[3].value)
|
||||
salary_date = {
|
||||
'sequence': row[0].value,
|
||||
'code':yuthon_company2+abbreviation,
|
||||
'name': row[1].value, # 姓名
|
||||
'struct_id': struct_id.id, # 部门
|
||||
'yuthon_company': yuthon_company,
|
||||
'amount_fix' : row[4].value, # 固定金额
|
||||
}
|
||||
salary_name.create(salary_date)
|
||||
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:
|
||||
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[10].value)
|
||||
yuthon_company2 = yuthon_company_dict2.get(row[10].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)
|
||||
@@ -324,13 +324,53 @@
|
||||
<menuitem id="human_pay_setting_structural_root_board"
|
||||
name="职级"
|
||||
parent="human_pay_setting_root_board"
|
||||
action="hr_payroll.action_view_hr_payroll_structure_list_form"
|
||||
sequence="1"/>
|
||||
<menuitem id="human_pay_setting_structural_root_board1"
|
||||
name="全部"
|
||||
parent="human_pay_setting_structural_root_board"
|
||||
action="yuthon_salary.action_view_hr_payroll_structure_list_form"
|
||||
sequence="1"/>
|
||||
<menuitem id="human_pay_setting_structural_root_board2"
|
||||
name="天河投资"
|
||||
parent="human_pay_setting_structural_root_board"
|
||||
action="yuthon_salary.action_view_hr_payroll_structure_list_form1"
|
||||
sequence="3"/>
|
||||
<menuitem id="human_pay_setting_structural_root_board3"
|
||||
name="天河粮储"
|
||||
parent="human_pay_setting_structural_root_board"
|
||||
action="yuthon_salary.action_view_hr_payroll_structure_list_form2"
|
||||
sequence="5"/>
|
||||
<menuitem id="human_pay_setting_structural_root_board4"
|
||||
name="天河物管"
|
||||
parent="human_pay_setting_structural_root_board"
|
||||
action="yuthon_salary.action_view_hr_payroll_structure_list_form3"
|
||||
sequence="7"/>
|
||||
|
||||
<menuitem id="human_pay_setting_type_rules_root_board"
|
||||
name="工资项"
|
||||
parent="human_pay_setting_root_board"
|
||||
action="hr_payroll.action_salary_rule_form"
|
||||
sequence="5"/>
|
||||
<menuitem id="human_pay_setting_rules_root_board1"
|
||||
name="全部"
|
||||
parent="human_pay_setting_type_rules_root_board"
|
||||
action="yuthon_salary.action_salary_rule_form"
|
||||
sequence="1"/>
|
||||
<menuitem id="human_pay_setting_rules_root_board2"
|
||||
name="天河投资"
|
||||
parent="human_pay_setting_type_rules_root_board"
|
||||
action="yuthon_salary.action_salary_rule_form1"
|
||||
sequence="3"/>
|
||||
<menuitem id="human_pay_setting_rules_root_board3"
|
||||
name="天河粮储"
|
||||
parent="human_pay_setting_type_rules_root_board"
|
||||
action="yuthon_salary.action_salary_rule_form2"
|
||||
sequence="5"/>
|
||||
<menuitem id="human_pay_setting_rules_root_board4"
|
||||
name="天河物管"
|
||||
parent="human_pay_setting_type_rules_root_board"
|
||||
action="yuthon_salary.action_salary_rule_form3"
|
||||
sequence="7"/>
|
||||
|
||||
<menuitem id="human_pay_setting_type_rule_argument_root_board"
|
||||
name="工资项参数"
|
||||
parent="human_pay_setting_root_board"
|
||||
|
||||
Reference in New Issue
Block a user