diff options
| author | Meera Trambadia (OpenERP) <mtr@tinyerp.com> | 2011-09-16 11:11:38 +0530 |
|---|---|---|
| committer | Meera Trambadia (OpenERP) <mtr@tinyerp.com> | 2011-09-16 11:11:38 +0530 |
| commit | d979aad3de95ae24aa1db52cf17c4eecf3d3ce6b (patch) | |
| tree | 592698c8e0dab53fcd157dd456a800bd4a80b5bf /addons/hr_payroll/wizard | |
| parent | eea80125f7d1c739260929fb1f38866ef21439e1 (diff) | |
| parent | d101d3fbaaffe2d0219ac6cfeef50338a2501664 (diff) | |
[MERGE] branch merged with lp:openobject-addons
bzr revid: mtr@tinyerp.com-20110916054138-93b3caomaij5dyp4
Diffstat (limited to 'addons/hr_payroll/wizard')
9 files changed, 214 insertions, 247 deletions
diff --git a/addons/hr_payroll/wizard/__init__.py b/addons/hr_payroll/wizard/__init__.py index 2cf78e17b1c..62a0c2a5c5d 100644 --- a/addons/hr_payroll/wizard/__init__.py +++ b/addons/hr_payroll/wizard/__init__.py @@ -1,7 +1,7 @@ #-*- coding:utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved # d$ # @@ -20,9 +20,7 @@ # ############################################################################## +import hr_payroll_payslips_by_employees +import hr_payroll_contribution_register_report -import hr_payroll_employees_detail -#import hr_payroll_create_analytic -import hr_payroll_year_salary - -# 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/wizard/hr_payroll_contribution_register_report.py b/addons/hr_payroll/wizard/hr_payroll_contribution_register_report.py new file mode 100644 index 00000000000..14860cdc753 --- /dev/null +++ b/addons/hr_payroll/wizard/hr_payroll_contribution_register_report.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# +# 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 <http://www.gnu.org/licenses/>. +# +############################################################################## + +import time +from datetime import datetime +from dateutil import relativedelta + +from osv import osv, fields + +class payslip_lines_contribution_register(osv.osv_memory): + _name = 'payslip.lines.contribution.register' + _description = 'PaySlip Lines by Contribution Registers' + _columns = { + 'date_from': fields.date('Date From', required=True), + 'date_to': fields.date('Date To', required=True), + } + + _defaults = { + 'date_from': lambda *a: time.strftime('%Y-%m-01'), + 'date_to': lambda *a: str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10], + } + + def print_report(self, cr, uid, ids, context=None): + datas = { + 'ids': context.get('active_ids', []), + 'model': 'hr.contribution.register', + 'form': self.read(cr, uid, ids, [], context=context)[0] + } + return { + 'type': 'ir.actions.report.xml', + 'report_name': 'contribution.register.lines', + 'datas': datas, + } + +payslip_lines_contribution_register() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll/wizard/hr_payroll_contribution_register_report.xml b/addons/hr_payroll/wizard/hr_payroll_contribution_register_report.xml new file mode 100644 index 00000000000..cb787cf536e --- /dev/null +++ b/addons/hr_payroll/wizard/hr_payroll_contribution_register_report.xml @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_payslip_lines_contribution_register" model="ir.ui.view"> + <field name="name">payslip.lines.contribution.register</field> + <field name="model">payslip.lines.contribution.register</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Contribution Register's Payslip Lines"> + <group col="4" colspan="6"> + <field name="date_from"/> + <newline/> + <field name="date_to"/> + </group> + <separator colspan="4"/> + <group col="2" colspan="4"> + <button special="cancel" string="Cancel" icon='gtk-cancel'/> + <button name="print_report" string="Print" colspan="1" type="object" icon="gtk-print"/> + </group> + </form> + </field> + </record> + + <record id="action_payslip_lines_contribution_register" model="ir.actions.act_window"> + <field name="name">PaySlip Lines</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">payslip.lines.contribution.register</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + </record> + + <record model="ir.values" id="payslip_lines_contribution_register_value"> + <field name="model_id" ref="model_hr_contribution_register" /> + <field name="object" eval="1" /> + <field name="name">PaySlip Lines</field> + <field name="key2">client_print_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_payslip_lines_contribution_register'))" /> + <field name="key">action</field> + <field name="model">hr.contribution.register</field> + </record> + + </data> +</openerp>
\ No newline at end of file diff --git a/addons/hr_payroll/wizard/hr_payroll_employees_detail.py b/addons/hr_payroll/wizard/hr_payroll_employees_detail.py deleted file mode 100644 index 2cb14a53f82..00000000000 --- a/addons/hr_payroll/wizard/hr_payroll_employees_detail.py +++ /dev/null @@ -1,74 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). -# -# 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 <http://www.gnu.org/licenses/>. -# -############################################################################## - -import time - -from osv import fields, osv - -class hr_payroll_employees_detail(osv.osv_memory): - - _name ='hr.payroll.employees.detail' - _columns = { - 'employee_ids': fields.many2many('hr.employee', 'payroll_emp_rel','payroll_id','emp_id', 'Employees',required=True), - 'date_from': fields.date('Start Date', required=True), - 'date_to': fields.date('End Date', required=True), - #'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True) - } -# def _get_fiscalyear(self, cr, uid, ids, context=None): -# if context is None: -# context = {} -# fiscal_ids = self.pool.get('account.fiscalyear').search(cr,uid,[], context=context) -# if fiscal_ids: -# return fiscal_ids[0] -# return False - - _defaults = { -# 'fiscalyear_id':_get_fiscalyear, - 'date_from': lambda *a: time.strftime('%Y-01-01'), - 'date_to': lambda *a: time.strftime('%Y-%m-%d'), - - } - - def print_report(self, cr, uid, ids, context=None): - """ - 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 - """ - if context is None: - context = {} - datas = {'ids': context.get('active_ids', [])} - res = self.read(cr, uid, ids, ['employee_ids', 'date_from', 'date_to'], context=context) - res = res and res[0] or {} - datas['form'] = res - datas['ids'] = res.get('employee_ids',[]) - return { - 'type': 'ir.actions.report.xml', - 'report_name': 'employees.salary', - 'datas': datas, - } - -hr_payroll_employees_detail() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll/wizard/hr_payroll_employees_detail.xml b/addons/hr_payroll/wizard/hr_payroll_employees_detail.xml deleted file mode 100644 index e65278e1b94..00000000000 --- a/addons/hr_payroll/wizard/hr_payroll_employees_detail.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<openerp> - <data> - <record id="view_hr_payroll_employees_detail" model="ir.ui.view"> - <field name="name">Employee Salary Statement</field> - <field name="model">hr.payroll.employees.detail</field> - <field name="type">form</field> - <field name="arch" type="xml"> - <form string="Year Salary"> - <group col="4" colspan="4"> - <group colspan="4"> - <field name="date_from" colspan="2"/> - <field name="date_to" colspan="2"/> - <newline/> - <separator string="Employees" colspan="4"/> - <field name="employee_ids" nolabel="1" colspan="4" /> - </group> - <newline/> - <group col="2" colspan="1"> - <button icon='gtk-cancel' special="cancel" - string="Close" /> - <button name="print_report" string="Print Report" - type="object" icon="gtk-print" /> - </group> - </group> - </form> - </field> - </record> - <record id="action_hr_payroll_employees_detail" model="ir.actions.act_window"> - <field name="name">Employee Salary Statement</field> - <field name="type">ir.actions.act_window</field> - <field name="res_model">hr.payroll.employees.detail</field> - <field name="view_type">form</field> - <field name="view_mode">form</field> - <field name="target">new</field> - </record> - - <menuitem id="menu_hr_payroll_employees_detail" - icon="STOCK_PRINT" - action="action_hr_payroll_employees_detail" - parent="menu_hr_payroll_reporting" - name="Employee Salary Statement"/> -</data> -</openerp> diff --git a/addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.py b/addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.py new file mode 100644 index 00000000000..5d806d3809b --- /dev/null +++ b/addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# +# 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 <http://www.gnu.org/licenses/>. +# +############################################################################## + +import time +from datetime import datetime +from dateutil import relativedelta + +from osv import fields, osv +from tools.translate import _ + +class hr_payslip_employees(osv.osv_memory): + + _name ='hr.payslip.employees' + _description = 'Generate payslips for all selected employees' + _columns = { + 'employee_ids': fields.many2many('hr.employee', 'hr_employee_group_rel', 'payslip_id', 'employee_id', 'Employees'), + } + + def compute_sheet(self, cr, uid, ids, context=None): + emp_pool = self.pool.get('hr.employee') + slip_pool = self.pool.get('hr.payslip') + run_pool = self.pool.get('hr.payslip.run') + slip_ids = [] + if context is None: + context = {} + data = self.read(cr, uid, ids, context=context)[0] + run_data = {} + if context and context.get('active_id', False): + run_data = run_pool.read(cr, uid, context['active_id'], ['date_start', 'date_end', 'credit_note']) + from_date = run_data.get('date_start', False) + to_date = run_data.get('date_end', False) + credit_note = run_data.get('credit_note', False) + if not data['employee_ids']: + raise osv.except_osv(_("Warning !"), _("You must select employee(s) to generate payslip(s)")) + for emp in emp_pool.browse(cr, uid, data['employee_ids'], context=context): + slip_data = slip_pool.onchange_employee_id(cr, uid, [], from_date, to_date, emp.id, contract_id=False, context=context) + res = { + 'employee_id': emp.id, + 'name': slip_data['value'].get('name', False), + 'struct_id': slip_data['value'].get('struct_id', False), + 'contract_id': slip_data['value'].get('contract_id', False), + 'payslip_run_id': context.get('active_id', False), + 'input_line_ids': [(0, 0, x) for x in slip_data['value'].get('input_line_ids', False)], + 'worked_days_line_ids': [(0, 0, x) for x in slip_data['value'].get('worked_days_line_ids', False)], + 'date_from': from_date, + 'date_to': to_date, + 'credit_note': credit_note, + } + slip_ids.append(slip_pool.create(cr, uid, res, context=context)) + slip_pool.compute_sheet(cr, uid, slip_ids, context=context) + return {'type': 'ir.actions.act_window_close'} + +hr_payslip_employees() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.xml b/addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.xml new file mode 100644 index 00000000000..60b25bbd95a --- /dev/null +++ b/addons/hr_payroll/wizard/hr_payroll_payslips_by_employees.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_hr_payslip_by_employees" model="ir.ui.view"> + <field name="name">hr_payroll_payslip_employees</field> + <field name="model">hr.payslip.employees</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Payslips by Employees"> + <label colspan="4" nolabel="1" string="This wizard will generate payslips for all selected employee(s) based on the dates and credit note specified on Payslips Run." /> + <group colspan="4" > + <separator string="Employees" colspan="4"/> + <newline/> + <field name="employee_ids" nolabel="1"/> + </group> + <separator string="" colspan="4" /> + <group colspan="4" col="6"> + <label string ="" colspan="2"/> + <button icon="gtk-cancel" special="cancel" string="Cancel"/> + <button icon="gtk-execute" string="Generate" name="compute_sheet" type="object"/> + </group> + </form> + </field> + </record> + + <record id="action_hr_payslip_by_employees" model="ir.actions.act_window"> + <field name="name">Generate Payslips</field> + <field name="res_model">hr.payslip.employees</field> + <field name="view_type">form</field> + <field name="view_mode">tree,form</field> + <field name="view_id" ref="view_hr_payslip_by_employees"/> + <field name="target">new</field> + </record> + + </data> +</openerp> diff --git a/addons/hr_payroll/wizard/hr_payroll_year_salary.py b/addons/hr_payroll/wizard/hr_payroll_year_salary.py deleted file mode 100644 index cb7d73b6394..00000000000 --- a/addons/hr_payroll/wizard/hr_payroll_year_salary.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). -# -# 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 <http://www.gnu.org/licenses/>. -# -############################################################################## - -import time - -from osv import fields, osv - -class hr_payroll_year_salary(osv.osv_memory): - _name = "hr.payroll.year.salary" - _columns = { - 'employee_ids': fields.many2many('hr.employee', 'payroll_year_rel','payroll_year_id','emp_id', 'Employees',required=True), - 'date_from': fields.date('Start Date', required=True), - 'date_to': fields.date('End Date', required=True), - #'fiscalyear_id': fields.many2one('account.fiscalyear', 'Fiscal Year', required=True) , - 'salary_on': fields.selection([('current_month','Current Month Date'),('next_month','Next Month Date')],'Salary On'), - } - -# def _get_fiscalyear(self, cr, uid, ids, context=None): -# if context is None: -# context = {} -# fiscal_ids=self.pool.get('account.fiscalyear').search(cr, uid, [], context=context) -# if fiscal_ids: -# return fiscal_ids[0] -# return False - - _defaults = { - # 'fiscalyear_id':_get_fiscalyear, - 'date_from': lambda *a: time.strftime('%Y-01-01'), - 'date_to': lambda *a: time.strftime('%Y-%m-%d'), - 'salary_on': 'current_month' - } - - def print_report(self, cr, uid, ids, context=None): - """ - 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 - """ - if context is None: - context = {} - datas = {'ids': context.get('active_ids', [])} - - res = self.read(cr, uid, ids, ['employee_ids', 'date_from', 'date_to', 'salary_on'], context=context) - res = res and res[0] or {} - datas['form'] = res - datas['ids'] = res.get('employee_ids',[]) - return { - 'type': 'ir.actions.report.xml', - 'report_name': 'year.salary', - 'datas': datas, - } - -hr_payroll_year_salary() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll/wizard/hr_payroll_year_salary.xml b/addons/hr_payroll/wizard/hr_payroll_year_salary.xml deleted file mode 100644 index 9d0252ca075..00000000000 --- a/addons/hr_payroll/wizard/hr_payroll_year_salary.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<openerp> - <data> - <record id="view_hr_payroll_year_salary" model="ir.ui.view"> - <field name="name">Salary Register</field> - <field name="model">hr.payroll.year.salary</field> - <field name="type">form</field> - <field name="arch" type="xml"> - <form string="Year Salary"> - <group col="4" colspan="4" > - <group colspan="4"> - <field name="date_from" colspan="2"/> - <field name="date_to" colspan="2"/> - <newline/> - <separator string="Employees" colspan="4"/> - <field name="employee_ids" nolabel="1" colspan="4"/> - <newline/> - </group> - <newline/> - <group> - <button icon='gtk-cancel' special="cancel" - string="Close" /> - <button name="print_report" string="Print Report" - type="object" icon="gtk-print" /> - </group> - </group> - </form> - </field> - </record> - <record id="action_hr_payroll_year_salary" model="ir.actions.act_window"> - <field name="name">Salary Register</field> - <field name="type">ir.actions.act_window</field> - <field name="res_model">hr.payroll.year.salary</field> - <field name="view_type">form</field> - <field name="view_mode">form</field> - <field name="target">new</field> - </record> - - <menuitem id="menu_wizard_print_year_salary" - icon="STOCK_PRINT" - action="action_hr_payroll_year_salary" - parent="menu_hr_payroll_reporting" - name="Salary Register" - /> - -</data> -</openerp> |
