From c1e2b36ab235f362bf4b260108ce9465afab4ff6 Mon Sep 17 00:00:00 2001 From: zhouzhou <123@qq.com> Date: Fri, 15 Nov 2024 20:07:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/yuthon_hr_department.py | 12 +++- .../models/yuthon_hr_employee.py | 5 +- yuthon_hr_employee/models/yuthon_job_lv.py | 4 +- yuthon_salary/__init__.py | 3 + yuthon_salary/__manifest__.py | 20 ++++++ yuthon_salary/models/__init__.py | 1 + .../models/inherit_hr_payroll_structure.py | 36 ++++++++++ yuthon_salary/security/ir.model.access.csv | 1 + .../inherit_hr_payroll_structure_views.xml | 64 ++++++++++++++++++ yuthon_work_brand/__manifest__.py | 1 + yuthon_work_brand/views/hr_menus.xml | 65 ++++++------------- 11 files changed, 161 insertions(+), 51 deletions(-) create mode 100644 yuthon_salary/__init__.py create mode 100644 yuthon_salary/__manifest__.py create mode 100644 yuthon_salary/models/__init__.py create mode 100644 yuthon_salary/models/inherit_hr_payroll_structure.py create mode 100644 yuthon_salary/security/ir.model.access.csv create mode 100644 yuthon_salary/views/inherit_hr_payroll_structure_views.xml diff --git a/yuthon_hr_employee/models/yuthon_hr_department.py b/yuthon_hr_employee/models/yuthon_hr_department.py index dd3b15b59..eb2717a3e 100644 --- a/yuthon_hr_employee/models/yuthon_hr_department.py +++ b/yuthon_hr_employee/models/yuthon_hr_department.py @@ -28,6 +28,7 @@ class YuthonHrDepartment(models.Model): else: code.department_code = code.department_code code.update_code() + def update_code(self): def cycle_code(parent,parent_code): for child in parent.lower_ids: @@ -35,4 +36,13 @@ class YuthonHrDepartment(models.Model): self.env['hr.department'].search([('id', '=', child.id.origin)]).write({'department_code': new_code}) cycle_code(child,new_code) - cycle_code(self, self.department_code) \ No newline at end of file + cycle_code(self, self.department_code) + + def name_get(self): + result = [] + for record in self: + name = record.name + if record.parent_id: + name = f"({record.parent_id.name})-{name}" + result.append((record.id, name)) + return result \ No newline at end of file diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py index d857f18c4..ff227a937 100644 --- a/yuthon_hr_employee/models/yuthon_hr_employee.py +++ b/yuthon_hr_employee/models/yuthon_hr_employee.py @@ -171,8 +171,9 @@ class YuthonHrEmployee(models.Model): for record in self: if record.social_insurance_time : today = datetime.now().date() - delta = relativedelta(today, record.social_insurance_date) - record.cumulative_work_month = delta.years * 12 + delta.months + if record.social_insurance_date: + delta = relativedelta(today, record.social_insurance_date) + record.cumulative_work_month = delta.years * 12 + delta.months else: record.cumulative_work_month = 0 diff --git a/yuthon_hr_employee/models/yuthon_job_lv.py b/yuthon_hr_employee/models/yuthon_job_lv.py index 9cb68f7eb..435d43500 100644 --- a/yuthon_hr_employee/models/yuthon_job_lv.py +++ b/yuthon_hr_employee/models/yuthon_job_lv.py @@ -48,9 +48,9 @@ class YuthonJobLv(models.Model): number_str = "".join(match) try: number = int(number_str) - return (not number_str.startswith('0'), number) + return (not number_str.startswith('0'), number) # 取反,首位为0的在前面 except ValueError: - return (False, 0) + return (False, 0) # 首位非0的放前面 return (False, 0) # 首位非0的放前面 res.sort(key=sort_by_sequence_number) diff --git a/yuthon_salary/__init__.py b/yuthon_salary/__init__.py new file mode 100644 index 000000000..cde864bae --- /dev/null +++ b/yuthon_salary/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/yuthon_salary/__manifest__.py b/yuthon_salary/__manifest__.py new file mode 100644 index 000000000..d225fe239 --- /dev/null +++ b/yuthon_salary/__manifest__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +{ + 'name': "yuthon salary", + 'summary': "薪资管理", + 'description': """ + + """, + 'author': 'pengyuthon', + 'website': 'https://www.pengyuthon.com', + 'category': 'Human Resources/Attendances', + 'version': '0.1', + 'license': 'LGPL-3', + 'depends': ['mail', 'base', 'hr', 'yuthon_hr_employee','hr_payroll'], + 'data': [ + 'security/ir.model.access.csv', + 'views/inherit_hr_payroll_structure_views.xml', + ], + 'installable': True, + 'application': True, +} diff --git a/yuthon_salary/models/__init__.py b/yuthon_salary/models/__init__.py new file mode 100644 index 000000000..a880a0e43 --- /dev/null +++ b/yuthon_salary/models/__init__.py @@ -0,0 +1 @@ +from . import inherit_hr_payroll_structure \ No newline at end of file diff --git a/yuthon_salary/models/inherit_hr_payroll_structure.py b/yuthon_salary/models/inherit_hr_payroll_structure.py new file mode 100644 index 000000000..49e9b5133 --- /dev/null +++ b/yuthon_salary/models/inherit_hr_payroll_structure.py @@ -0,0 +1,36 @@ +from odoo import api, fields, models, _ +import re + +class HrPayrollStructure(models.Model): + _inherit = 'hr.payroll.structure' + _order = 'sequence asc' + + lv = fields.Char(string="级别") + name = fields.Char(string="级别名称") + sequence = fields.Char(string='级别序号', store=True) + yuthon_company = fields.Selection([('thtz', '天河投资集团'), ('thwg', '天河物管'), ('thlc', '天河粮储'), + ('tctj', '天投城建')], string='公司') + create_time = fields.Datetime(string="生效日期", default=fields.Datetime.now) + end_time = fields.Datetime(string="失效日期") + + @api.model + def read_group(self, domain, fields, groupby, offset=0, limit=None, orderby=False, lazy=True): + res = super(HrPayrollStructure, self).read_group(domain, fields, groupby, offset=offset, limit=limit, orderby=orderby, + lazy=lazy) + if 'lv' in groupby: + def sort_by_sequence_number(item): + lv = item.get('lv') + if lv: + rec = self.search([('lv', '=', lv)], limit=1) + if rec and rec.sequence: + match = re.findall(r'\d+', rec.sequence) + if match: + number_str = "".join(match) + try: + number = int(number_str) + return (not number_str.startswith('0'), number) + except ValueError: + return (False, 0) + return (False, 0) # 首位非0的放前面 + res.sort(key=sort_by_sequence_number) + return res \ No newline at end of file diff --git a/yuthon_salary/security/ir.model.access.csv b/yuthon_salary/security/ir.model.access.csv new file mode 100644 index 000000000..97dd8b917 --- /dev/null +++ b/yuthon_salary/security/ir.model.access.csv @@ -0,0 +1 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink diff --git a/yuthon_salary/views/inherit_hr_payroll_structure_views.xml b/yuthon_salary/views/inherit_hr_payroll_structure_views.xml new file mode 100644 index 000000000..916951aba --- /dev/null +++ b/yuthon_salary/views/inherit_hr_payroll_structure_views.xml @@ -0,0 +1,64 @@ + + + + hr.payroll.structure.inherit + hr.payroll.structure + + + + 1 + + + 1 + + + 级别名称 + + + + + + + + + + + + + + hr.payroll.structure.inherit.form + hr.payroll.structure + + + + + + + + + + + 级别名称 + + + + + hr.payroll.structure.inherit.search + hr.payroll.structure + + + + + + + + + + + + 薪资管理 + hr.payroll.structure + tree,form,search + {'search_default_group_lv': 1} + + \ No newline at end of file diff --git a/yuthon_work_brand/__manifest__.py b/yuthon_work_brand/__manifest__.py index e7bd05e62..ed4274f78 100644 --- a/yuthon_work_brand/__manifest__.py +++ b/yuthon_work_brand/__manifest__.py @@ -22,6 +22,7 @@ 'website', 'yuthon_hr_employee', 'yuthon_sps_approval', + 'yuthon_salary', 'sale', 'payment', 'purchase', diff --git a/yuthon_work_brand/views/hr_menus.xml b/yuthon_work_brand/views/hr_menus.xml index 9c69dcb43..a98fdf2dc 100644 --- a/yuthon_work_brand/views/hr_menus.xml +++ b/yuthon_work_brand/views/hr_menus.xml @@ -514,17 +514,8 @@ - - + sequence="5"/> - - - - - - + sequence="1"/> + +