diff --git a/addons/hr_payroll/__openerp__.py b/addons/hr_payroll/__openerp__.py index 8bfa8510322..93b64e89741 100644 --- a/addons/hr_payroll/__openerp__.py +++ b/addons/hr_payroll/__openerp__.py @@ -56,6 +56,7 @@ Generic Payroll system. 'hr_payroll_report.xml', 'hr_payroll_data.xml', 'security/ir.model.access.csv', + 'wizard/hr_payroll_contribution_register_report.xml', ], 'test': [ # 'test/payslip.yml', diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 134c73a125e..5ba5dbac216 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -314,7 +314,7 @@ class hr_payslip(osv.osv): def hr_verify_sheet(self, cr, uid, ids, context=None): return self.write(cr, uid, ids, {'state': 'verify'}, context=context) - + def refund_sheet(self, cr, uid, ids, context=None): mod_obj = self.pool.get('ir.model.data') wf_service = netsvc.LocalService("workflow") @@ -545,7 +545,7 @@ class hr_payslip(osv.osv): inputs = {} for input_line in payslip.input_line_ids: inputs[input_line.code] = input_line - + categories_obj = BrowsableObject(self.pool, cr, uid, payslip.employee_id.id, categories_dict) input_obj = InputLine(self.pool, cr, uid, payslip.employee_id.id, inputs) worked_days_obj = WorkedDays(self.pool, cr, uid, payslip.employee_id.id, worked_days) @@ -769,16 +769,7 @@ class hr_salary_rule(osv.osv): 'amount_python_compute':fields.text('Python Code'), 'amount_percentage_base':fields.char('Percentage based on',size=1024, required=False, readonly=False, help='result will be affected to a variable'), 'child_ids':fields.one2many('hr.salary.rule', 'parent_rule_id', 'Child Salary Rule'), - 'register_id':fields.property( - 'hr.contribution.register', - type='many2one', - relation='hr.contribution.register', - string="Contribution Register", - method=True, - view_load=True, - help="Contribution register based on company", - required=False - ), + 'register_id':fields.many2one('hr.contribution.register', 'Contribution Register', help="Contribution register for the rule"), 'input_ids': fields.one2many('hr.rule.input', 'input_id', 'Inputs'), 'note':fields.text('Description'), } @@ -790,7 +781,7 @@ class hr_salary_rule(osv.osv): # employee: hr.employee object # contract: hr.contract object # rules: object containing the rules code (previously computed) -# categories: object containing the computed salary rule categories (sum of amount of all rules belonging to that category). +# categories: object containing the computed salary rule categories (sum of amount of all rules belonging to that category). # worked_days: object containing the computed worked days. # inputs: object containing the computed inputs. @@ -805,7 +796,7 @@ result = contract.wage * 0.10''', # employee: hr.employee object # contract: hr.contract object # rules: object containing the rules code (previously computed) -# categories: object containing the computed salary rule categories (sum of amount of all rules belonging to that category). +# categories: object containing the computed salary rule categories (sum of amount of all rules belonging to that category). # worked_days: object containing the computed worked days # inputs: object containing the computed inputs diff --git a/addons/hr_payroll/hr_payroll_report.xml b/addons/hr_payroll/hr_payroll_report.xml index d701add9dc5..a0027d70e0d 100644 --- a/addons/hr_payroll/hr_payroll_report.xml +++ b/addons/hr_payroll/hr_payroll_report.xml @@ -18,5 +18,14 @@ rml="hr_payroll/report/report_payslip_details.rml" string="PaySlip Details" /> + + diff --git a/addons/hr_payroll/report/__init__.py b/addons/hr_payroll/report/__init__.py index 17d38ecbed5..8de2f51d18f 100644 --- a/addons/hr_payroll/report/__init__.py +++ b/addons/hr_payroll/report/__init__.py @@ -24,5 +24,6 @@ import report_payslip import report_payslip_details +import report_contribution_register -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll/report/report_contribution_register.py b/addons/hr_payroll/report/report_contribution_register.py new file mode 100644 index 00000000000..bd9e00d3832 --- /dev/null +++ b/addons/hr_payroll/report/report_contribution_register.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +#-*- coding:utf-8 -*- + +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). All Rights Reserved +# d$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import time +from datetime import datetime +from dateutil import relativedelta + +from report import report_sxw + +class contribution_register_report(report_sxw.rml_parse): + def __init__(self, cr, uid, name, context): + super(contribution_register_report, self).__init__(cr, uid, name, context) + self.localcontext.update({ + 'get_payslip_lines': self._get_payslip_lines, + 'sum_total': self.sum_total, + }) + + def set_context(self, objects, data, ids, report_type=None): + self.date_from = data['form'].get('date_from', time.strftime('%Y-%m-%d')) + self.date_to = data['form'].get('date_to', str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10]) + return super(contribution_register_report, self).set_context(objects, data, ids, report_type=report_type) + + def sum_total(self): + return self.regi_total + + def _get_payslip_lines(self, obj): + payslip_obj = self.pool.get('hr.payslip') + payslip_line = self.pool.get('hr.payslip.line') + payslip_lines = [] + res = [] + self.regi_total = 0.0 + self.cr.execute("SELECT pl.id from hr_payslip_line as pl "\ + "LEFT JOIN hr_payslip AS hp on (pl.slip_id = hp.id) "\ + "WHERE (hp.date_from >= %s) AND (hp.date_to <= %s) "\ + "AND pl.register_id = %s "\ + "ORDER BY pl.slip_id, pl.sequence", + (self.date_from, self.date_to, obj.id)) + payslip_lines = [x[0] for x in self.cr.fetchall()] + for line in payslip_line.browse(self.cr, self.uid, payslip_lines): + res.append({ + 'payslip_name': line.slip_id.name, + 'name': line.name, + 'code': line.code, + 'quantity': line.quantity, + 'amount': line.amount, + 'total': line.total, + }) + self.regi_total += line.total + return res + +report_sxw.report_sxw('report.contribution.register.lines', 'hr.contribution.register', 'hr_payroll/report/report_contribution_register.rml', parser=contribution_register_report) + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/hr_payroll/report/report_contribution_register.rml b/addons/hr_payroll/report/report_contribution_register.rml new file mode 100644 index 00000000000..fedacc8786e --- /dev/null +++ b/addons/hr_payroll/report/report_contribution_register.rml @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[repeatIn(objects,'o')]] + + + + PaySlip Lines by Contribution Register + + + + + + + + + + + + + + Register Name + + + Date From + + + Date To + + + + + + + [[ o.name or '']] + + + [[ data['form']['date_from'] or '']] + + + [[ data['form']['date_to'] or '' ]] + + + + + + + + + + + + + + PaySlip Name + + + Code + + + Name + + + Quantity/Rate + + + Amount + + + Total + + + + + + +
+ [[repeatIn(get_payslip_lines(o),'r') ]] + + + + [[ r.get('payslip_name', False) ]][[ r.get('payslip_name', False) and ( setTag('para','para',{'style':'terp_default_8'})) or removeParentNode('font')]] + + + [[ r['code'] ]] + + + [[ r['name'] ]] + + + [[ formatLang(r['quantity']) ]] + + + [[ formatLang(r['amount']) ]] + + + [[ formatLang(r['total']) ]] [[o.company_id and o.company_id.currency_id.symbol or '']] + + + +
+ + + + + + + + + Total: + + + [[ formatLang(abs(sum_total())) ]] [[o.company_id and o.company_id.currency_id.symbol or '']] + + + + + + +
+
+ diff --git a/addons/hr_payroll/wizard/__init__.py b/addons/hr_payroll/wizard/__init__.py index 039c875ed98..62a0c2a5c5d 100644 --- a/addons/hr_payroll/wizard/__init__.py +++ b/addons/hr_payroll/wizard/__init__.py @@ -21,5 +21,6 @@ ############################################################################## import hr_payroll_payslips_by_employees +import hr_payroll_contribution_register_report -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: