4 ##############################################################################
6 # OpenERP, Open Source Management Solution
7 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU Affero General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU Affero General Public License for more details.
20 # You should have received a copy of the GNU Affero General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 ##############################################################################
25 from openerp.report import report_sxw
27 class fiche_paye_parser(report_sxw.rml_parse):
29 def __init__(self, cr, uid, name, context):
30 super(fiche_paye_parser, self).__init__(cr, uid, name, context)
31 self.localcontext.update({
32 'get_payslip_lines': self.get_payslip_lines,
33 'get_total_by_rule_category': self.get_total_by_rule_category,
34 'get_employer_line': self.get_employer_line,
37 def get_payslip_lines(self, objs):
38 payslip_line = self.pool.get('hr.payslip.line')
42 if item.appears_on_payslip == True and not item.salary_rule_id.parent_rule_id :
45 res = payslip_line.browse(self.cr, self.uid, ids)
49 def get_total_by_rule_category(self, obj, code):
50 payslip_line = self.pool.get('hr.payslip.line')
51 rule_cate_obj = self.pool.get('hr.salary.rule.category')
53 cate_ids = rule_cate_obj.search(self.cr, self.uid, [('code', '=', code)])
57 line_ids = payslip_line.search(self.cr, self.uid, [('slip_id', '=', obj.id),('category_id.id', '=', cate_ids[0] )])
58 for line in payslip_line.browse(self.cr, self.uid, line_ids):
59 category_total += line.total
64 def get_employer_line(self, obj, parent_line):
66 payslip_line = self.pool.get('hr.payslip.line')
68 line_ids = payslip_line.search(self.cr, self.uid, [('slip_id', '=', obj.id), ('salary_rule_id.parent_rule_id.id', '=', parent_line.salary_rule_id.id )])
69 res = line_ids and payslip_line.browse(self.cr, self.uid, line_ids[0]) or False
74 report_sxw.report_sxw('report.fiche.paye', 'hr.payslip', 'l10n_fr_hr_payroll/report/fiche_paye.rml', parser=fiche_paye_parser)
76 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: