From 0f5d7b52da02c6580de9ed5612583cff60d6146f Mon Sep 17 00:00:00 2001 From: "sbh (Open ERP)" Date: Wed, 30 Jun 2010 17:46:32 +0530 Subject: [PATCH] [IMP] hr_payroll: convert the wizard_employees_detail into osv_memeroy bzr revid: sbh@tinyerp.com-20100630121632-i37b2t5wh26zu2l8 --- addons/hr_payroll/__openerp__.py | 1 + .../report/report_employees_detail.py | 4 +- addons/hr_payroll/wizard/__init__.py | 2 +- .../wizard/hr_payroll_employees_detail.py | 66 +++++++++++++++++++ .../wizard/hr_payroll_employees_detail.xml | 38 +++++++++++ .../wizard/wizard_employees_detail.py | 60 ----------------- 6 files changed, 108 insertions(+), 63 deletions(-) create mode 100755 addons/hr_payroll/wizard/hr_payroll_employees_detail.py create mode 100644 addons/hr_payroll/wizard/hr_payroll_employees_detail.xml delete mode 100755 addons/hr_payroll/wizard/wizard_employees_detail.py diff --git a/addons/hr_payroll/__openerp__.py b/addons/hr_payroll/__openerp__.py index 6f569ddda55..07ba77306f0 100644 --- a/addons/hr_payroll/__openerp__.py +++ b/addons/hr_payroll/__openerp__.py @@ -51,6 +51,7 @@ 'hr_paroll_report.xml', 'hr_payroll_data.xml', 'wizard/hr_payroll_create_analytic.xml', + 'wizard/hr_payroll_employees_detail.xml', 'hr_payroll_wizard.xml' ], 'demo_xml': [ diff --git a/addons/hr_payroll/report/report_employees_detail.py b/addons/hr_payroll/report/report_employees_detail.py index c809696a35b..c1f5146e4a9 100644 --- a/addons/hr_payroll/report/report_employees_detail.py +++ b/addons/hr_payroll/report/report_employees_detail.py @@ -70,8 +70,8 @@ class employees_salary_report(rml_parse.rml_parse): def get_employee(self,form): result = [] periods = [] - emp = pooler.get_pool(self.cr.dbname).get('hr.employee') - emp_ids = form['employee_ids'][0][2] + emp = pooler.get_pool(self.cr.dbname).get('hr.employee') + emp_ids = form['employee_ids'] result = emp.browse(self.cr,self.uid, emp_ids) fiscalyear_obj = pooler.get_pool(self.cr.dbname).get('account.fiscalyear').browse(self.cr, self.uid, form['fiscalyear_id']) period_ids_l = fiscalyear_obj.period_ids diff --git a/addons/hr_payroll/wizard/__init__.py b/addons/hr_payroll/wizard/__init__.py index 8ba60547cfe..0918085e334 100755 --- a/addons/hr_payroll/wizard/__init__.py +++ b/addons/hr_payroll/wizard/__init__.py @@ -1,3 +1,3 @@ -import wizard_year_salary +import hr_payroll_employees_detail import wizard_employees_detail import hr_payroll_create_analytic diff --git a/addons/hr_payroll/wizard/hr_payroll_employees_detail.py b/addons/hr_payroll/wizard/hr_payroll_employees_detail.py new file mode 100755 index 00000000000..c780ce03e8c --- /dev/null +++ b/addons/hr_payroll/wizard/hr_payroll_employees_detail.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 osv import fields, osv +from tools.translate import _ + +class hr_payroll_employees_detail(osv.osv): + _name = "hr.payroll.employees.detail" + _columns = { + 'employee_ids': fields.many2many('hr.employee', 'payroll_emp_rel','payroll_id','emp_id', 'Employees',required=True), + 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True) + } + def _get_defaults(self, cr, uid, ids, context={}): + fiscal_ids=self.pool.get('account.fiscalyear').search(cr,uid,[]) + if fiscal_ids: + return fiscal_ids[0] + return False + + _defaults = { + 'fiscalyear_id':_get_defaults, + } + + def print_report(self, cr, uid, ids, context={}): + """ + To get the date and print the report + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param context: A standard dictionary + @return : return report + """ + + datas = {'ids': context.get('active_ids', [])} + + res = self.read(cr, uid, ids, ['employee_ids', 'fiscalyear_id'], context) + res = res and res[0] or {} + datas['form'] = res + datas['form']['fiscalyear_id']=res['fiscalyear_id'][0] + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'employees.salary', + 'datas': datas, + 'nodestroy':True, + } + +hr_payroll_employees_detail() \ No newline at end of file diff --git a/addons/hr_payroll/wizard/hr_payroll_employees_detail.xml b/addons/hr_payroll/wizard/hr_payroll_employees_detail.xml new file mode 100644 index 00000000000..aed2e1f377b --- /dev/null +++ b/addons/hr_payroll/wizard/hr_payroll_employees_detail.xml @@ -0,0 +1,38 @@ + + + + + Employee Salary Statement + hr.payroll.employees.detail + form + +
+ + + + + +