diff --git a/addons/hr_payroll/report/report_payslip.py b/addons/hr_payroll/report/report_payslip.py index 0e6f9137330..31f99607a1e 100644 --- a/addons/hr_payroll/report/report_payslip.py +++ b/addons/hr_payroll/report/report_payslip.py @@ -37,8 +37,8 @@ class payslip_report(report_sxw.rml_parse): 'get_deductions':self.get_deductions, 'get_leave': self.get_leave, 'get_payslip_lines': self.get_payslip_lines, -# 'get_details_by_salary_head': self.get_details_by_salary_head - }) + 'get_details_by_salary_head': self.get_details_by_salary_head, + }) def convert(self, amount, cur): amt_en = amount_to_text_en.amount_to_text(amount, 'en', cur) @@ -84,7 +84,7 @@ class payslip_report(report_sxw.rml_parse): date = datetime.strptime(obj.date, '%Y-%m-%d') res['mname']= date.strftime('%B')+"-"+date.strftime('%Y') return res['mname'] - + def get_payslip_lines(self, obj): payslip_line = self.pool.get('hr.payslip.line') res = [] @@ -96,6 +96,54 @@ class payslip_report(report_sxw.rml_parse): res = payslip_line.browse(self.cr, self.uid, ids) return res + def get_recursive_parent(self, heads): + if not heads: + return [] + if heads[0].parent_id: + heads.insert(0, heads[0].parent_id) + self.get_recursive_parent(heads) + return heads + + def get_details_by_salary_head(self, obj): + payslip_line = self.pool.get('hr.payslip.line') + salary_head = self.pool.get('hr.salary.head') + res = [] + result = {} + ids = [] + for id in range(len(obj)): + ids.append(obj[id].id) + if ids: + self.cr.execute('''SELECT pl.id, pl.category_id FROM hr_payslip_line as pl \ + LEFT JOIN hr_salary_head AS sh on (pl.category_id = sh.id) \ + WHERE pl.id in %s \ + GROUP BY sh.parent_id, sh.sequence, pl.sequence, pl.id, pl.category_id \ + ORDER BY sh.sequence, pl.sequence, sh.parent_id''',(tuple(ids),)) + for x in self.cr.fetchall(): + result.setdefault(x[1], []) + result[x[1]].append(x[0]) + for key, value in result.iteritems(): + heads = salary_head.browse(self.cr, self.uid, [key]) + parents = self.get_recursive_parent(heads) + level = 0 + for parent in parents: + res.append({ + 'salary_head': parent.name, + 'name': parent.name, + 'code': parent.code, + 'level': level + }) + level += 1 + lines = payslip_line.browse(self.cr, self.uid, value) + for line in lines: + res.append({ + 'salary_head': line.name, + 'name': line.name, + 'code': line.code, + 'total': line.total, + 'level': level + }) + return res + report_sxw.report_sxw('report.payslip.pdf', 'hr.payslip', 'hr_payroll/report/payslip.rml', parser=payslip_report) report_sxw.report_sxw('report.test.pdf', 'hr.payslip', 'hr_payroll/report/report_payslip.rml', parser=payslip_report) diff --git a/addons/hr_payroll/report/report_payslip.rml b/addons/hr_payroll/report/report_payslip.rml index a827ee3ce7b..31e71f9c98f 100644 --- a/addons/hr_payroll/report/report_payslip.rml +++ b/addons/hr_payroll/report/report_payslip.rml @@ -10,73 +10,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -96,248 +34,379 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + - [[repeatIn(objects,'o')]] - + [[repeatIn(objects,'o')]] + - Pay Slip - - + Pay Slip + + + + + [[o.credit_note==False and removeParentNode('para')]] + Credit + + Note + + ([[o.name]]) + + + + Name + + + [[o.employee_id.name]] + + + Designation + + + [[ o.employee_id.contract_id and o.employee_id.contract_id.job_id.name or '' ]] + + + + + + + + Address - - - - - - - - Code - - - [[ o.employee_id.sinid or '' ]] - - - Name - - - [[o.employee_id.name]] + [[o.employee_id.address_home_id and o.employee_id.address_home_id.name or '' ]],[[o.employee_id.address_home_id and o.employee_id.address_home_id.street or '' ]],[[o.employee_id.address_home_id and o.employee_id.address_home_id.street2 or '' ]],[[o.employee_id.address_home_id and o.employee_id.address_home_id.zip or '' ]],[[o.employee_id.address_home_id and o.employee_id.address_home_id.city or '' ]],[[o.employee_id.address_home_id and o.employee_id.address_home_id.state_id and o.employee_id.address_home_id.state_id.name or '' ]] [[o.employee_id.address_home_id and o.employee_id.address_home_id.country_id and o.employee_id.address_home_id.country_id.name or '' ]] - + - Address + Email - [[o.employee_id.address_home_id and o.employee_id.address_home_id.name or '' ]],[[o.employee_id.address_home_id and o.employee_id.address_home_id.street or '' ]],[[o.employee_id.address_home_id and o.employee_id.address_home_id.street2 or '' ]],[[o.employee_id.address_home_id and o.employee_id.address_home_id.zip or '' ]],[[o.employee_id.address_home_id and o.employee_id.address_home_id.city or '' ]],[[o.employee_id.address_home_id and o.employee_id.address_home_id.state_id and o.employee_id.address_home_id.state_id.name or '' ]] [[o.employee_id.address_home_id and o.employee_id.address_home_id.country_id and o.employee_id.address_home_id.country_id.name or '' ]] + [[ o.employee_id.work_email or '' ]] + + + + Identification No + + + + [[ o.employee_id.identification_id or '' ]] - + - Email + Slip ID - [[ o.employee_id.work_email or '' ]] + [[ o.number or '' ]] - Bank Details + Bank Details - [[ o.employee_id.otherid or '' ]] + [[ o.employee_id.otherid or '' ]] - + - Slip ID + Date From - [[ o.number or '' ]] + [[ o.date_from or '']] - Identification No + + Date To + - [[ o.employee_id.passport_id and o.employee_id.passport_id.name or '' ]] + [[ o.date_to or '' ]] - - - - Register - - - [[ o.register_id and o.register_id.name or '' ]] - - - Designation - - - [[ o.employee_id.contract_id and o.employee_id.contract_id.job_id.name or '' ]] - - - - - - Payslip Lines - - - - - Sequence - - - Name - - - Code - - - Sub Total - - - - - [[repeatIn(get_payslip_lines(o.line_ids),'p') ]] [[ p.sequence ]] - - - [[ p.name ]] - - - [[ p.code ]] - - - [[ p.total ]] [[ o.company_id and o.company_id.currency_id.symbol or '' ]] - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - - - - - - + + - + Payslip Lines: + + + + + + + Code + + + Name + + + Amount (in [[o.company_id and o.company_id.currency_id.symbol or '']]) + + + +
+ [[repeatIn(get_payslip_lines(o.line_ids),'p') ]] + + + + [[ p.code ]] + + + [[ p.name ]] + + + [[ p.total or '0.0']] + + + +
+ + + + + + + Details By Salary Head: + + + + + + + Code + + + Salary Head + + + Name + + + Amount(in [[o.company_id and o.company_id.currency_id.symbol or '']]) + + + +
+ [[repeatIn(get_details_by_salary_head(o.line_ids),'h') ]] + + + + + [[ h['code'] ]] + [[ h['total'] and ( setTag('para','para',{'style':'terp_default_8'}))]] + + + + [[ '..'*h['level'] ]][[ h['salary_head'] ]][[ h['total'] and ( setTag('para','para',{'style':'terp_default_9'}))]] + + + [[ h['name'] ]][[ h['total'] and ( setTag('para','para',{'style':'terp_default_8'}))]] + + + [[ h['total'] ]] + + + +
+ + + + + + + + + + + + + - Authorized Signature + Authorized Signature - +