From ad2c5c052d8dea4ae76762079ed08cf25be3e976 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Thu, 15 May 2025 19:23:32 +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 --- .../views/yuthon_hr_department_views.xml | 6 +-- yuthon_salary/__manifest__.py | 1 + yuthon_salary/models/__init__.py | 3 +- yuthon_salary/models/inherit_hr_payslip.py | 2 + .../models/salary_payroll_distribution.py | 25 +++++++++++ .../models/yuthon_salary_documents.py | 35 ++++++++++++++- yuthon_salary/security/ir.model.access.csv | 3 +- .../security/salary_security_rule.xml | 5 +++ .../views/inherit_hr_payslip_views.xml | 16 ++----- .../salary_payroll_distribution_viwes.xml | 21 +++++++++ .../views/yuthon_salary_documents_views.xml | 1 + yuthon_work_brand/views/hr_menus.xml | 45 +++++++------------ 12 files changed, 116 insertions(+), 47 deletions(-) create mode 100644 yuthon_salary/models/salary_payroll_distribution.py create mode 100644 yuthon_salary/views/salary_payroll_distribution_viwes.xml diff --git a/yuthon_hr_employee/views/yuthon_hr_department_views.xml b/yuthon_hr_employee/views/yuthon_hr_department_views.xml index 8e5e9f98d..22417ea12 100644 --- a/yuthon_hr_employee/views/yuthon_hr_department_views.xml +++ b/yuthon_hr_employee/views/yuthon_hr_department_views.xml @@ -15,9 +15,9 @@ True - - - +
+
1 diff --git a/yuthon_salary/__manifest__.py b/yuthon_salary/__manifest__.py index 3ce607f8e..fadf8d798 100644 --- a/yuthon_salary/__manifest__.py +++ b/yuthon_salary/__manifest__.py @@ -21,6 +21,7 @@ 'views/yuthon_payroll_project_views.xml', 'views/yuthon_payroll_type_setting_views.xml', 'views/yuthon_salary_asset_views.xml', + 'views/salary_payroll_distribution_viwes.xml', 'views/yuthon_salary_project_views.xml', 'views/yuthon_payroll_labor_views.xml', 'views/yuthon_salary_documents_views.xml', diff --git a/yuthon_salary/models/__init__.py b/yuthon_salary/models/__init__.py index b336d872f..776b35227 100644 --- a/yuthon_salary/models/__init__.py +++ b/yuthon_salary/models/__init__.py @@ -9,4 +9,5 @@ from . import yuthon_payroll_retired from . import yuthon_salary_documents from . import yuthon_salary_year from . import yuthon_salary_project -from . import yuthon_salary_asset \ No newline at end of file +from . import yuthon_salary_asset +from . import salary_payroll_distribution \ No newline at end of file diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py index 3007716bb..67e5cf146 100644 --- a/yuthon_salary/models/inherit_hr_payslip.py +++ b/yuthon_salary/models/inherit_hr_payslip.py @@ -333,6 +333,7 @@ class InheritHrPayslip(models.Model): self.env['hr.payslip.line'].create(payslips._get_payslip_lines()) return True + # 薪资归档 def put_release(self): for record in self: record.write({ @@ -340,6 +341,7 @@ class InheritHrPayslip(models.Model): 'salary_state': 'to_release', }) + # 薪资归档 def all_put_release(self): payslip_ids = self.env["hr.payslip"].browse(self._context.get('active_ids', self._context.get('active_id'))) for record in payslip_ids: diff --git a/yuthon_salary/models/salary_payroll_distribution.py b/yuthon_salary/models/salary_payroll_distribution.py new file mode 100644 index 000000000..446fc5ac3 --- /dev/null +++ b/yuthon_salary/models/salary_payroll_distribution.py @@ -0,0 +1,25 @@ +from odoo import api, fields, models + + +class SalaryPayrollDistribution(models.Model): + _name = 'salary.payroll.distribution' + _description = '薪资发放' + + salary_group_id = fields.Many2one('yuthon.salary.group', string="工资单分组", store=True) + actual_salary = fields.Float(string='实发工资', store=True) + current_year = fields.Integer(string='年份') + current_month = fields.Selection([ + ('1', '1月份'), + ('2', '2月份'), + ('3', '3月份'), + ('4', '4月份'), + ('5', '5月份'), + ('6', '6月份'), + ('7', '7月份'), + ('8', '8月份'), + ('9', '9月份'), + ('10', '10月份'), + ('11', '11月份'), + ('12', '12月份') + ], string="月份") + company_id = fields.Many2one('res.company', string='公司', index=True, default=lambda self: self.env.company) \ No newline at end of file diff --git a/yuthon_salary/models/yuthon_salary_documents.py b/yuthon_salary/models/yuthon_salary_documents.py index 6dd24449f..af07b8bca 100644 --- a/yuthon_salary/models/yuthon_salary_documents.py +++ b/yuthon_salary/models/yuthon_salary_documents.py @@ -21,4 +21,37 @@ class YuthonSalaryDocuments(models.Model): ('12', '12月份') ], string="月份") company_id = fields.Many2one('res.company', string='公司', index=True, default=lambda self: self.env.company) - documents_ids = fields.Many2many('ir.attachment', string="附件") \ No newline at end of file + documents_ids = fields.Many2many('ir.attachment', string="附件") + + def documents_confirm(self): + month = int(self.current_month) + month_mapping = { + 1: '一月', 2: '二月', 3: '三月', 4: '四月', + 5: '五月', 6: '六月', 7: '七月', 8: '八月', + 9: '九月', 10: '十月', 11: '十一月', 12: '十二月' + } + month_name = month_mapping.get(month, '一月') + payslip_ids = self.env['hr.payslip'].search([ + ('is_salary_release', '=', False), + ('is_salary_push', '=', True), + ('payslip_run_id.name', '=', f'{self.current_year}年-{month_name}'), + ('company_id', '=', self.company_id.id) # 确保公司一致 + ]) + + # 按工资组分组并计算总和 + group_data = {} + for payslip in payslip_ids: + group_id = payslip.salary_group_id.id + if group_id not in group_data: + group_data[group_id] = { + 'salary_group_id': group_id, + 'actual_salary': 0.0, + 'current_year': self.current_year, + 'current_month': self.current_month, + 'company_id': self.company_id.id + } + group_data[group_id]['actual_salary'] += payslip.actual_salary + + distribution_model = self.env['salary.payroll.distribution'] + for group_id, data in group_data.items(): + distribution_model.create(data) diff --git a/yuthon_salary/security/ir.model.access.csv b/yuthon_salary/security/ir.model.access.csv index 7da6a723d..87f08cda7 100644 --- a/yuthon_salary/security/ir.model.access.csv +++ b/yuthon_salary/security/ir.model.access.csv @@ -27,4 +27,5 @@ access_yuthon_salary_documents,access_yuthon_salary_documents,model_yuthon_salar access_salary_print_wizard, access_salary_print_wizard,model_salary_print_wizard,base.group_user,1,1,1,1 access_salary_year_wizard,access_salary_year_wizard,model_salary_year_wizard,base.group_user,1,1,1,1 access_yuthon_salary_project, access_yuthon_salary_project,model_yuthon_salary_project,base.group_user,1,1,1,1 -access_yuthon_salary_asset, access_yuthon_salary_asset,model_yuthon_salary_asset,base.group_user,1,1,1,1 \ No newline at end of file +access_yuthon_salary_asset, access_yuthon_salary_asset,model_yuthon_salary_asset,base.group_user,1,1,1,1 +access_salary_payroll_distribution,access_salary_payroll_distribution,model_salary_payroll_distribution,base.group_user,1,1,1,1 diff --git a/yuthon_salary/security/salary_security_rule.xml b/yuthon_salary/security/salary_security_rule.xml index eaa13d047..47c38ffb0 100644 --- a/yuthon_salary/security/salary_security_rule.xml +++ b/yuthon_salary/security/salary_security_rule.xml @@ -1,5 +1,10 @@ + + 薪资方法多公司 + + [('company_id', 'in', company_ids)] + 常用项多公司 diff --git a/yuthon_salary/views/inherit_hr_payslip_views.xml b/yuthon_salary/views/inherit_hr_payslip_views.xml index 93c97f250..ae905c367 100644 --- a/yuthon_salary/views/inherit_hr_payslip_views.xml +++ b/yuthon_salary/views/inherit_hr_payslip_views.xml @@ -87,15 +87,12 @@ - + hr.payslip.tree hr.payslip - -
-
+ @@ -394,7 +391,7 @@ {'search_default_group_by_employee': 1}
- 薪资发放 + 薪资归档 hr.payslip tree,form,search [('is_salary_push', '=', True), ('is_salary_release', '=', True)] @@ -430,13 +427,6 @@ code action = model.action_return_salary_wizard() - - 批量推送薪资发放 - - - code - action = model.all_put_release() - 批量退回薪资审定 diff --git a/yuthon_salary/views/salary_payroll_distribution_viwes.xml b/yuthon_salary/views/salary_payroll_distribution_viwes.xml new file mode 100644 index 000000000..4e14bff48 --- /dev/null +++ b/yuthon_salary/views/salary_payroll_distribution_viwes.xml @@ -0,0 +1,21 @@ + + + + salary.payroll.distribution.tree + salary.payroll.distribution + + + + + + + + + + + + 薪资发放 + salary.payroll.distribution + tree + + diff --git a/yuthon_salary/views/yuthon_salary_documents_views.xml b/yuthon_salary/views/yuthon_salary_documents_views.xml index 0dc2436cb..fb2fbd0cc 100644 --- a/yuthon_salary/views/yuthon_salary_documents_views.xml +++ b/yuthon_salary/views/yuthon_salary_documents_views.xml @@ -9,6 +9,7 @@ +