[MERGE] lp:~xrg/openobject-addons/trunk-patch18
[odoo/odoo.git] / addons / hr_payroll / report / report_emp_salary_structure.py
1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3
4 ##############################################################################
5 #
6 #    OpenERP, Open Source Management Solution
7 #    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 #    d$
9 #
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.
14 #
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.
19 #
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/>.
22 #
23 ##############################################################################
24
25 import time
26 from report import report_sxw
27
28 class salary_structure_report(report_sxw.rml_parse):
29
30     def __init__(self, cr, uid, name, context):
31           super(salary_structure_report, self).__init__(cr, uid, name, context)
32           self.localcontext.update({
33             'time': time,
34             'get_type':self.get_type,
35             #'get_contract':self.get_contract,
36             'get_line_amount_type':self.get_line_amount_type,
37             'get_line_type':self.get_line_type,
38             'get_line_amount_symbol':self.get_line_amount_symbol
39           })
40
41 #    def get_contract(self,emp):
42 #        curr_date = "'"+time.strftime("%Y-%m-%d")+"'"
43 #        sql_req= '''
44 #            SELECT c.id as id, c.wage as wage, struct_id as struct
45 #            FROM hr_contract c
46 #              LEFT JOIN hr_employee emp on (c.employee_id=emp.id)
47 #              LEFT JOIN hr_contract_wage_type cwt on (cwt.id = c.wage_type_id)
48 #              LEFT JOIN hr_contract_wage_type_period p on (cwt.period_id = p.id)
49 #            WHERE
50 #              (emp.id=%s) AND
51 #              (date_start <= %s) AND
52 #              (date_end IS NULL OR date_end >= %s)
53 #            LIMIT 1
54 #            '''%(emp.id, curr_date, curr_date)
55 #        self.cr.execute(sql_req)
56 #        contract_id = self.cr.dictfetchone()
57 #        if not contract_id:
58 #            return []
59 #        contract = self.pool.get('hr.contract').browse(self.cr, self.uid, [contract_id['id']])
60 #        return contract
61
62     def get_type(self,type):
63         return type[0].swapcase() + type[1:] +' Salary'
64
65     def get_line_amount_type(self,amount_type):
66         if amount_type == 'per':
67             return 'Percent(%)'
68         else:
69             return 'Fixed'
70
71     def get_line_amount_symbol(self,amount_type):
72         if amount_type != 'per':
73             return self.pool.get('res.users').browse(self.cr, self.uid,self.uid).company_id.currency_id.symbol
74
75     def get_line_type(self,type):
76         if type == 'allounce':
77             return 'Allowance'
78         elif type == 'deduction':
79             return 'Deduction'
80         elif type == 'advance':
81             return 'Advance'
82         elif type == 'loan':
83             return 'Loan'
84         elif type == 'otherpay':
85             return 'Other Payment'
86         else:
87             return 'Other Deduction'
88
89 report_sxw.report_sxw('report.salary.structure', 'hr.employee', 'hr_payroll/report/report_emp_salary_structure.rml', parser=salary_structure_report)
90
91 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
92
93
94
95
96
97
98