Merge pull request !1822 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2025-03-15 07:24:40 +00:00
committed by Gitee
+27 -15
View File
@@ -8,10 +8,9 @@ class YuthonPayrollCommon(models.Model):
_description = '薪资常用项'
name = fields.Char(string='工资项名称')
yuthon_company = fields.Selection([('thtz', '天河投资集团'), ('thwg', '天河物管'), ('thlc', '天河粮储')],
string='公司')
yuthon_company = fields.Selection([('thtz', '天河投资集团'), ('thwg', '天河物管'), ('thlc', '天河粮储')],string='公司')
department_id = fields.Many2one('hr.department', string="部门")
conditional_formulas = fields.Char(string='条件公式') # todo 可能是个many2one
conditional_formulas = fields.Char(string='条件公式')
start_date = fields.Date(string="生效日期", default=fields.Date.today())
end_date = fields.Date(string="失效日期")
@@ -19,22 +18,41 @@ class YuthonPayrollCommon(models.Model):
"""
更新常用项职级
:return:
# Available variables:
#----------------------
# payslip: hr.payslip object
# employee: hr.employee object
# contract: hr.contract object
# rules: dict containing the rules code (previously computed)
# categories: dict containing the computed salary rule categories (sum of amount of all rules belonging to that category).
# worked_days: dict containing the computed worked days
# inputs: dict containing the computed inputs.
# Note: returned value have to be set in the variable 'result'
result = contract.wage * 0.10
"""
insurances_ids = self.env["yuthon.payroll.insurances"].browse(self._context.get('active_ids', self._context.get('active_id')))
insurances_ids = self.env["yuthon.payroll.common"].browse(self._context.get('active_ids', self._context.get('active_id')))
for ins in insurances_ids:
salary_lv_ids = self.env["yuthon.payroll.common"].search([])
salary_lv_ids = self.env["hr.payroll.structure"].search([])
for sal in salary_lv_ids:
rule_list = []
formula_salary = ''
if ins.name not in sal.rule_ids.mapped('name'):
# 工资项公式
if ins.name == '工龄':
formula_salary = "result = int((employee.cumulative_work_month / 12) * 10)"
if ins.name == '工会会费':
formula_salary = "result = contract.wage * 0.05"
if ins.name == '加班费':
formula_salary = "result = employee.all_overtime_hours - 40 * contract.wage /21.75 / 8"
rule_list.append([0, 0, {
'name': ins.name,
'category_id': self.env['hr.salary.rule.category'].search([('name', '=', '常用项')], limit=1).id,
'code': "".join([p[0][0] for p in pinyin(ins.name, style=Style.FIRST_LETTER)]).upper(),
'amount_select': 'code',
# 'amount_percentage_base': sal.base_salary,
'quantity': 1,
# 'amount_percentage': ins.proportion_employee,
'struct_id': sal.id
'amount_python_compute': formula_salary,
'struct_id': sal.id,
}])
sal.write({'rule_ids': rule_list})
@@ -50,12 +68,6 @@ class YuthonPayrollTemporary(models.Model):
start_date = fields.Date(string="生效日期", default=fields.Date.today())
end_date = fields.Date(string="失效日期")
class YuthonPayrollInsurances2(models.Model):
_name = 'yuthon.disease.approval'
class YuthonPayrollInsurances3(models.Model):
_name = 'yuthon.hospital.approval'
class YuthonPayrollInsurances (models.Model):
_name = 'yuthon.payroll.insurances'
_description = '五险一金'