Merge branch 'dev' into dev_zhou

This commit is contained in:
zhou
2025-03-27 16:07:58 +08:00
5 changed files with 72 additions and 13 deletions
@@ -8,6 +8,13 @@ class YuthonHrDepartment(models.Model):
_rec_name = 'name'
_order = 'department_code asc'
def change_company_id(self):
company_dict = {'thtz':'集团本部', 'thwg':'天河物管', 'thlc':'天河粮储', }
employee_ids = self.browse(self._context.get('active_ids', self._context.get('active_id')))
for i in employee_ids:
company_id = self.env['res.company'].search([('name', '=', company_dict[i.yuthon_company])])
i.company_id = company_id
department_phone = fields.Char(string="部门电话")
department_fax = fields.Char(string="部门传真")
department_location = fields.Char(string="部门地址")
@@ -26,6 +26,12 @@ class YuthonHrEmployee(models.Model):
_inherit = "hr.employee"
_order = 'number asc'
def change_company_id(self):
company_dict = {'thtz':'集团本部', 'thwg':'天河物管', 'thlc':'天河粮储', }
employee_ids = self.browse(self._context.get('active_ids', self._context.get('active_id')))
for i in employee_ids:
company_id = self.env['res.company'].search([('name', '=', company_dict[i.yuthon_company])])
i.company_id = company_id
# odoo里是这样做的,一个用户可以多个公司绑定多个员工,每个员工都有自己的部门和岗位
user_role_ids_changed = fields.Boolean(string="xxx") # bug
wecom_userid = fields.Char(string="成员UserID", default="")
@@ -171,6 +177,7 @@ class YuthonHrEmployee(models.Model):
@api.depends('social_base_on', 'social_base_off')
def _compute_insurance_bases(self):
current_month = datetime.now().month
self.medical_insurance_base = self.pension_insurance_base = self.work_injury_insurance_base = self.housing_fund_base = 0
if 1 <= current_month <= 6:
base = self.social_base_on
else:
@@ -394,6 +394,26 @@
<field name="state">code</field>
<field name="code">action = model.action_hr_employee()</field>
</record>
<record id="all_data_employee_company_id" model="ir.actions.server">
<field name="name">测试更新公司company_id</field>
<field name="model_id" ref="hr.model_hr_employee"/>
<field name="binding_model_id" ref="hr.model_hr_employee"/>
<field name="state">code</field>
<field name="code">action = model.change_company_id()</field>
</record>
<record id="all_data_department_company_id" model="ir.actions.server">
<field name="name">测试更新公司company_id</field>
<field name="model_id" ref="hr.model_hr_employee"/>
<field name="binding_model_id" ref="hr.model_hr_employee"/>
<field name="state">code</field>
<field name="code">action = model.change_company_id()</field>
</record>
<record id="hr.open_view_employee_list_my" model="ir.actions.act_window">
<field name="view_mode">tree,kanban,form,activity,graph,pivot,hierarchy</field>
</record>
@@ -75,6 +75,17 @@ class InheritHrPayslip(models.Model):
commuting_deduction = fields.Float(string='扣发通勤补贴', store=True)
base_salary_deduction = fields.Float(string='扣发基本工资', store=True)
def action_refresh_from_work_entries(self):
if any(p.state not in ['draft', 'verify'] for p in self):
raise UserError(_('The payslips should be in Draft or Waiting state.'))
payslip_records = self.browse(self._context.get('active_ids', self._context.get('active_id')))
for pay in payslip_records:
# payslips = self.filtered(lambda p: not p.edited)
pay.mapped('worked_days_line_ids').unlink()
pay.mapped('line_ids').unlink()
pay._compute_worked_days_line_ids()
pay.compute_sheet()
@api.depends('line_ids')
def _compute_salary(self):
for rec in self:
+27 -13
View File
@@ -173,27 +173,41 @@ class YuthonPayrollInsurances (models.Model):
continue
rule_list = []
formula_salary = ''
number = ins.proportion_employee * 0.01
code = 'None'
if ins.name == '基本医疗保险费':
code = 'JBYLIAO'
formula_salary = "result = employee.medical_insurance_base * " + str(number)
if ins.name == '基本养老保险费':
code = 'JBYLAO'
formula_salary = "result = employee.pension_insurance_base * " + str(number)
if ins.name == '失业保险费':
code = 'SYBX'
formula_salary = "result = employee.social_base_on * " + str(number)
if ins.name == '工伤保险费':
code = 'GSBX'
formula_salary = "result = employee.work_injury_insurance_base * " + str(number)
if ins.name == '住房公积金':
code = 'ZFGJJ'
formula_salary = "result = employee.housing_fund_base * " + str(number)
if ins.name == '工会会费':
code = 'GHHF'
formula_salary = "result = round((payslip.base_salary * 0.005), 2)"
if ins.name == '企业(职业)年金':
code = 'QYNJ'
# formula_salary = "result = (employee.last_year_salary * 0.02) if employee.regularization_year != 0 else ((payslip.base_salary + payslip.rank_salary) * 0.02)"
formula_salary = "result = round((employee.last_year_salary * 0.02), 0)"
if ins.name not in sal.rule_ids.mapped('name'):
number = ins.proportion_employee * 0.01
if ins.name == '基本医疗保险费':
formula_salary = "result = employee.medical_insurance_base * " + str(number)
if ins.name == '基本养老保险费':
formula_salary = "result = employee.pension_insurance_base * " + str(number)
if ins.name == '失业保险费':
formula_salary = "result = employee.social_base_on * " + str(number)
if ins.name == '工伤保险费':
formula_salary = "result = employee.work_injury_insurance_base * " + str(number)
if ins.name == '住房公积金':
formula_salary = "result = employee.housing_fund_base * " + str(number)
code = "".join([p[0][0] for p in pinyin(ins.name, style=Style.FIRST_LETTER)]).upper()
rule_list.append([0, 0, {
'name': ins.name,
'category_id': self.env['hr.salary.rule.category'].search([('name', '=', '五险一金')], limit=1).id,
'code': code if ins.name != '基本养老保险费' else 'JBYLBXF2',
'code': code,
'amount_select': 'code',
'amount_python_compute': formula_salary,
'struct_id': sal.id,
}])
sal.write({'rule_ids': rule_list})
else:
sal.rule_ids.search([('name', '=', ins.name)]).write({'amount_python_compute': formula_salary})