From 7d7a331f6effb93de9133d5443d941e26ba7cf37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Thu, 27 Mar 2025 13:10:53 +0800 Subject: [PATCH 1/5] 1 --- yuthon_salary/models/yuthon_payroll_project.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/yuthon_salary/models/yuthon_payroll_project.py b/yuthon_salary/models/yuthon_payroll_project.py index a2c4e20c8..2a9cb37fd 100644 --- a/yuthon_salary/models/yuthon_payroll_project.py +++ b/yuthon_salary/models/yuthon_payroll_project.py @@ -175,21 +175,26 @@ class YuthonPayrollInsurances (models.Model): formula_salary = '' if ins.name not in sal.rule_ids.mapped('name'): 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) - 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, From 5039ee3f028a0754e8e4c7628c996fb1f025e937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Thu, 27 Mar 2025 13:43:55 +0800 Subject: [PATCH 2/5] 1 --- yuthon_salary/models/inherit_hr_payslip.py | 11 +++++++++++ yuthon_salary/models/yuthon_payroll_project.py | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py index 9efabd8c5..02b1ee96c 100644 --- a/yuthon_salary/models/inherit_hr_payslip.py +++ b/yuthon_salary/models/inherit_hr_payslip.py @@ -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: diff --git a/yuthon_salary/models/yuthon_payroll_project.py b/yuthon_salary/models/yuthon_payroll_project.py index 2a9cb37fd..b60794d14 100644 --- a/yuthon_salary/models/yuthon_payroll_project.py +++ b/yuthon_salary/models/yuthon_payroll_project.py @@ -191,6 +191,13 @@ class YuthonPayrollInsurances (models.Model): 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 = employee.last_year_salary * 0.02" rule_list.append([0, 0, { 'name': ins.name, 'category_id': self.env['hr.salary.rule.category'].search([('name', '=', '五险一金')], limit=1).id, From 8acb9faa9a5697de2f776879efaa4c6aa5a10cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Thu, 27 Mar 2025 13:53:04 +0800 Subject: [PATCH 3/5] 1 --- .../models/yuthon_payroll_project.py | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/yuthon_salary/models/yuthon_payroll_project.py b/yuthon_salary/models/yuthon_payroll_project.py index b60794d14..5195ea71f 100644 --- a/yuthon_salary/models/yuthon_payroll_project.py +++ b/yuthon_salary/models/yuthon_payroll_project.py @@ -173,31 +173,31 @@ 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 = employee.last_year_salary * 0.02" if ins.name not in sal.rule_ids.mapped('name'): - 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 = employee.last_year_salary * 0.02" rule_list.append([0, 0, { 'name': ins.name, 'category_id': self.env['hr.salary.rule.category'].search([('name', '=', '五险一金')], limit=1).id, @@ -207,5 +207,7 @@ class YuthonPayrollInsurances (models.Model): 'struct_id': sal.id, }]) sal.write({'rule_ids': rule_list}) + else: + sal.rule_ids.search([('name', '=', ins.name)]).write({'amount_python_compute': formula_salary}) From 366e44f5454893a973334566132ccd13c7c6c2b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Thu, 27 Mar 2025 14:01:46 +0800 Subject: [PATCH 4/5] 1 --- yuthon_salary/models/yuthon_payroll_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yuthon_salary/models/yuthon_payroll_project.py b/yuthon_salary/models/yuthon_payroll_project.py index 5195ea71f..af80b6875 100644 --- a/yuthon_salary/models/yuthon_payroll_project.py +++ b/yuthon_salary/models/yuthon_payroll_project.py @@ -196,7 +196,7 @@ class YuthonPayrollInsurances (models.Model): 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 = employee.last_year_salary * 0.02" + formula_salary = "result = round((employee.last_year_salary * 0.02), 0)" if ins.name not in sal.rule_ids.mapped('name'): rule_list.append([0, 0, { 'name': ins.name, From eb4509a68d2d43ab3d23942286f8155e6ff4a79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Thu, 27 Mar 2025 16:07:27 +0800 Subject: [PATCH 5/5] 1 --- .../models/yuthon_hr_department.py | 7 +++++++ .../models/yuthon_hr_employee.py | 7 +++++++ .../views/yuthon_hr_employee_views.xml | 20 +++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/yuthon_hr_employee/models/yuthon_hr_department.py b/yuthon_hr_employee/models/yuthon_hr_department.py index a625ffb19..f20abed1f 100644 --- a/yuthon_hr_employee/models/yuthon_hr_department.py +++ b/yuthon_hr_employee/models/yuthon_hr_department.py @@ -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="部门地址") diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py index 957bb408b..0032bf8f3 100644 --- a/yuthon_hr_employee/models/yuthon_hr_employee.py +++ b/yuthon_hr_employee/models/yuthon_hr_employee.py @@ -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: diff --git a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml index 851e8f0dd..93c408e65 100644 --- a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml +++ b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml @@ -394,6 +394,26 @@ code action = model.action_hr_employee() + + + + + 测试更新公司company_id + + + code + action = model.change_company_id() + + + 测试更新公司company_id + + + code + action = model.change_company_id() + + + + tree,kanban,form,activity,graph,pivot,hierarchy