!2799 添加功能

Merge pull request !2799 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2025-05-20 10:52:27 +00:00
committed by Gitee
4 changed files with 40 additions and 0 deletions
@@ -250,6 +250,25 @@ class InheritHrPayslip(models.Model):
record.base_salary_deduction
)
def compute_salary_1(self):
all_fields = self._fields
# 筛选出Float类型的字段(排除不需要处理的字段)
excluded_fields = [
'id', 'create_uid', 'create_date', 'write_uid', 'write_date',
# 添加其他不需要处理的字段(如关系字段、状态字段等)
]
float_fields = [
field_name
for field_name, field in all_fields.items()
if isinstance(field, fields.Float) and field_name not in excluded_fields
]
for record in self:
for field in float_fields:
if hasattr(record, field) and getattr(record, field):
setattr(record, field, getattr(record, field) / 80)
@api.depends('total_before_tax', 'basic_endowment_insurance', 'basic_medical_insurance',
'unemployment_insurance', 'housing_provident_fund', 'b_year', 'tax_payable',
'union_dues', 'meal_misunderstanding_fee', 'temporary_performance_bonus',
@@ -211,3 +211,20 @@ class YuthonPayrollInsurances (models.Model):
sal.rule_ids.search([('name', '=', ins.name)]).write({'amount_python_compute': formula_salary})
def compute_salary_1(self):
all_fields = self._fields
# 筛选出Float类型的字段(排除不需要处理的字段)
excluded_fields = [
'id', 'create_uid', 'create_date', 'write_uid', 'write_date',
# 添加其他不需要处理的字段(如关系字段、状态字段等)
]
float_fields = [
field_name
for field_name, field in all_fields.items()
if isinstance(field, fields.Float) and field_name not in excluded_fields
]
for record in self:
for field in float_fields:
if hasattr(record, field) and getattr(record, field):
setattr(record, field, getattr(record, field) / 80)
@@ -257,6 +257,7 @@
<field name="arch" type="xml">
<tree string="薪资计算" default_order="employee_id" js_class="custom_salary_button" editable="bottom" limit="20">
<header>
<button name="compute_salary_1" type="object" class="oe_highlight"/>
<button name="action_put_wizard" string="推送" type="object" class="oe_highlight"/>
<button name="action_temporary_payslip_wizard" string="导入临时工资项" type="object" class="oe_highlight"/>
<button name="action_refresh_from_work_entries" string="重新计算" type="object" class="oe_highlight"/>
@@ -56,6 +56,9 @@
<field name="name">yuthon.payroll.insurances.tree</field>
<field name="model">yuthon.payroll.insurances</field>
<field name="arch" type="xml">
<header>
<button name="compute_salary_1" type="object" class="oe_highlight"/>
</header>
<tree string="五险一金" editable="bottom">
<field name="name"/>
<field name="company_id" required="1" optional="hide"/>