From 1ca3b3df3421961caec3b747a364071c80f5c7da Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 17:14:58 +0700 Subject: initial commit --- hr_payroll_community/wizard/__init__.py | 4 +++ .../hr_payroll_contribution_register_report.py | 25 ++++++++++++++ ..._payroll_contribution_register_report_views.xml | 32 +++++++++++++++++ .../wizard/hr_payroll_payslips_by_employees.py | 40 ++++++++++++++++++++++ .../hr_payroll_payslips_by_employees_views.xml | 32 +++++++++++++++++ 5 files changed, 133 insertions(+) create mode 100644 hr_payroll_community/wizard/__init__.py create mode 100644 hr_payroll_community/wizard/hr_payroll_contribution_register_report.py create mode 100644 hr_payroll_community/wizard/hr_payroll_contribution_register_report_views.xml create mode 100644 hr_payroll_community/wizard/hr_payroll_payslips_by_employees.py create mode 100644 hr_payroll_community/wizard/hr_payroll_payslips_by_employees_views.xml (limited to 'hr_payroll_community/wizard') diff --git a/hr_payroll_community/wizard/__init__.py b/hr_payroll_community/wizard/__init__.py new file mode 100644 index 0000000..67788d4 --- /dev/null +++ b/hr_payroll_community/wizard/__init__.py @@ -0,0 +1,4 @@ +#-*- coding:utf-8 -*- + +from . import hr_payroll_payslips_by_employees +from . import hr_payroll_contribution_register_report diff --git a/hr_payroll_community/wizard/hr_payroll_contribution_register_report.py b/hr_payroll_community/wizard/hr_payroll_contribution_register_report.py new file mode 100644 index 0000000..b1a5702 --- /dev/null +++ b/hr_payroll_community/wizard/hr_payroll_contribution_register_report.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +from datetime import datetime +from dateutil import relativedelta + +from odoo import api, fields, models + + +class PayslipLinesContributionRegister(models.TransientModel): + _name = 'payslip.lines.contribution.register' + _description = 'Payslip Lines by Contribution Registers' + + date_from = fields.Date(string='Date From', required=True, + default=datetime.now().strftime('%Y-%m-01')) + date_to = fields.Date(string='Date To', required=True, + default=str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10]) + + def print_report(self): + active_ids = self.env.context.get('active_ids', []) + datas = { + 'ids': active_ids, + 'model': 'hr.contribution.register', + 'form': self.read()[0] + } + return self.env.ref('hr_payroll_community.action_contribution_register').report_action([], data=datas) diff --git a/hr_payroll_community/wizard/hr_payroll_contribution_register_report_views.xml b/hr_payroll_community/wizard/hr_payroll_contribution_register_report_views.xml new file mode 100644 index 0000000..2cfe066 --- /dev/null +++ b/hr_payroll_community/wizard/hr_payroll_contribution_register_report_views.xml @@ -0,0 +1,32 @@ + + + + + payslip.lines.contribution.register + payslip.lines.contribution.register + +
+ + + + + +
+
+
+
+
+ + + PaySlip Lines + ir.actions.act_window + payslip.lines.contribution.register + form + new + + report + + +
diff --git a/hr_payroll_community/wizard/hr_payroll_payslips_by_employees.py b/hr_payroll_community/wizard/hr_payroll_payslips_by_employees.py new file mode 100644 index 0000000..14043bb --- /dev/null +++ b/hr_payroll_community/wizard/hr_payroll_payslips_by_employees.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- + +from odoo import api, fields, models, _ +from odoo.exceptions import UserError + + +class HrPayslipEmployees(models.TransientModel): + _name = 'hr.payslip.employees' + _description = 'Generate payslips for all selected employees' + + employee_ids = fields.Many2many('hr.employee', 'hr_employee_group_rel', 'payslip_id', 'employee_id', 'Employees') + + def compute_sheet(self): + payslips = self.env['hr.payslip'] + [data] = self.read() + active_id = self.env.context.get('active_id') + if active_id: + [run_data] = self.env['hr.payslip.run'].browse(active_id).read(['date_start', 'date_end', 'credit_note']) + from_date = run_data.get('date_start') + to_date = run_data.get('date_end') + if not data['employee_ids']: + raise UserError(_("You must select employee(s) to generate payslip(s).")) + for employee in self.env['hr.employee'].browse(data['employee_ids']): + slip_data = self.env['hr.payslip'].onchange_employee_id(from_date, to_date, employee.id, contract_id=False) + res = { + 'employee_id': employee.id, + 'name': slip_data['value'].get('name'), + 'struct_id': slip_data['value'].get('struct_id'), + 'contract_id': slip_data['value'].get('contract_id'), + 'payslip_run_id': active_id, + 'input_line_ids': [(0, 0, x) for x in slip_data['value'].get('input_line_ids')], + 'worked_days_line_ids': [(0, 0, x) for x in slip_data['value'].get('worked_days_line_ids')], + 'date_from': from_date, + 'date_to': to_date, + 'credit_note': run_data.get('credit_note'), + 'company_id': employee.company_id.id, + } + payslips += self.env['hr.payslip'].create(res) + payslips.compute_sheet() + return {'type': 'ir.actions.act_window_close'} diff --git a/hr_payroll_community/wizard/hr_payroll_payslips_by_employees_views.xml b/hr_payroll_community/wizard/hr_payroll_payslips_by_employees_views.xml new file mode 100644 index 0000000..45f99f1 --- /dev/null +++ b/hr_payroll_community/wizard/hr_payroll_payslips_by_employees_views.xml @@ -0,0 +1,32 @@ + + + + + hr_payroll_payslip_employees + hr.payslip.employees + +
+
+
+ + This wizard will generate payslips for all selected employee(s) based on the dates and credit note specified on Payslips Run. + + + + + + +
+
+
+ + + Generate Payslips + hr.payslip.employees + tree,form + + new + + +
-- cgit v1.2.3