1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Addons modules by CLEARCORP S.A.
6
# Copyright (C) 2009-TODAY CLEARCORP S.A. (<http://clearcorp.co.cr>).
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU Affero General Public License as
10
# published by the Free Software Foundation, either version 3 of the
11
# License, or (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU Affero General Public License for more details.
18
# You should have received a copy of the GNU Affero General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
23
from report import report_sxw
24
from report.report_sxw import rml_parse
25
import openerp.pooler as pooler
26
from openerp.tools.translate import _
28
class Parser(report_sxw.rml_parse):
29
def __init__(self, cr, uid, name, context):
30
super(Parser, self).__init__(cr, uid, name, context)
32
self.pool = pooler.get_pool(cr.dbname)
33
self.localcontext.update({
34
'get_label_name': self.get_label_name,
35
'get_label_amount': self.get_label_amount,
36
'get_label_account': self.get_label_account,
37
'compute_payslip_lines': self.compute_payslip_lines,
40
def get_label_name(self):
41
return _('Employee Name')
43
def get_label_amount(self):
46
def get_label_account(self):
47
return _('Bank Account')
49
def compute_payslip_lines(self, data):
50
payslip_run_id = data.get('payslip_run_id', False)
51
if not payslip_run_id: return False
52
employee_ids = data.get('employee_ids', False)
53
if not employee_ids: return False
54
salary_rule_id = data.get('salary_rule_id', False)
55
if not salary_rule_id: return False
56
self.cr.execute("""SELECT EMP.name_related AS employee_name,
57
CASE WHEN EMP.bank_account_id IS NULL THEN ''
59
(SELECT BANK.acc_number
60
FROM res_partner_bank AS BANK
61
WHERE EMP.bank_account_id = BANK.id
65
(SELECT SUM(LINE.amount)
66
FROM hr_payslip_line AS LINE
67
WHERE LINE.slip_id = PAYSLIP.id AND
68
LINE.salary_rule_id = %s) IS NULL THEN 0.0
70
(SELECT SUM(LINE.amount)
71
FROM hr_payslip_line AS LINE
72
WHERE LINE.slip_id = PAYSLIP.id AND
73
LINE.salary_rule_id = %s)
75
FROM hr_employee as EMP,
76
hr_payslip as PAYSLIP,
77
hr_payslip_run as BATCH
78
WHERE EMP.id in %s AND
79
EMP.id = PAYSLIP.employee_id AND
80
BATCH.id = PAYSLIP.payslip_run_id AND
81
BATCH.id = %s""",[salary_rule_id, salary_rule_id, tuple(employee_ids), payslip_run_id])
82
result = self.cr.dictfetchall()
b'\\ No newline at end of file'