From bddfe1cd5a644ca6c0582aa6458988375a9a1ec3 Mon Sep 17 00:00:00 2001 From: "Mustufa Rangwala (OpenERP)" Date: Thu, 15 Sep 2011 10:46:36 +0530 Subject: [PATCH 1/2] [IMP] hr_payroll, hr_payroll_account: Payslip Run => add journal_id field on payslip run, improve search view, fix for done button on payslip run, usibility improvements bzr revid: mra@tinyerp.com-20110915051636-54xj84eams3fvyu5 --- addons/hr_payroll/hr_payroll.py | 1 + addons/hr_payroll/hr_payroll_view.xml | 5 ++- .../hr_payroll_account/hr_payroll_account.py | 9 +++++ .../hr_payroll_account_view.xml | 40 +++++++++++++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 464c3d295a4..f025addc61e 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -211,6 +211,7 @@ class one2many_mod2(fields.one2many): class hr_payslip_run(osv.osv): _name = 'hr.payslip.run' + _description = 'Payslip Run' _columns = { 'name': fields.char('Name', size=64, required=True, readonly=True, states={'draft': [('readonly', False)]}), 'slip_ids': fields.one2many('hr.payslip', 'payslip_run_id', 'Payslips', required=False, readonly=True, states={'draft': [('readonly', False)]}), diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index a2523fcb7ba..b11ca79c5f5 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -663,8 +663,8 @@ search - - + + @@ -683,6 +683,7 @@ + diff --git a/addons/hr_payroll_account/hr_payroll_account.py b/addons/hr_payroll_account/hr_payroll_account.py index 1ff19e01bb1..6eb0a6d1859 100644 --- a/addons/hr_payroll_account/hr_payroll_account.py +++ b/addons/hr_payroll_account/hr_payroll_account.py @@ -174,5 +174,14 @@ class hr_contract(osv.osv): } hr_contract() +class hr_payslip_run(osv.osv): + + _inherit = 'hr.payslip.run' + _description = 'Payslip Run' + _columns = { + 'journal_id': fields.many2one('account.journal', 'Expense Journal', states={'draft': [('readonly', False)]}, readonly=True, required=True), + } + +hr_payslip_run() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll_account/hr_payroll_account_view.xml b/addons/hr_payroll_account/hr_payroll_account_view.xml index 825fac9cab4..667b1308ec5 100644 --- a/addons/hr_payroll_account/hr_payroll_account_view.xml +++ b/addons/hr_payroll_account/hr_payroll_account_view.xml @@ -51,6 +51,46 @@ + + + + hr.payslip.run.search.inherit + hr.payslip.run + search + + + + + + + + + + + hr.payslip.run.tree.inherit + hr.payslip.run + tree + + + + + + + + + + hr.payslip.run.form.inherit + hr.payslip.run + form + + + + + + + + + From 36330b362adb731a2196f1e32352eced459a1848 Mon Sep 17 00:00:00 2001 From: "Mustufa Rangwala (OpenERP)" Date: Thu, 15 Sep 2011 11:15:39 +0530 Subject: [PATCH 2/2] [FIX] Hr_payroll: Inherit wizard of payslip runs to pass journl id on context which used to create payslips bzr revid: mra@tinyerp.com-20110915054539-2ihi7ls1wlxer72t --- addons/hr_payroll_account/__init__.py | 1 + .../hr_payroll_account/hr_payroll_account.py | 7 ++++ addons/hr_payroll_account/wizard/__init__.py | 25 ++++++++++++ .../hr_payroll_payslips_by_employees.py | 40 +++++++++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 addons/hr_payroll_account/wizard/__init__.py create mode 100644 addons/hr_payroll_account/wizard/hr_payroll_payslips_by_employees.py diff --git a/addons/hr_payroll_account/__init__.py b/addons/hr_payroll_account/__init__.py index ee7125d5411..ffe4b707ac0 100644 --- a/addons/hr_payroll_account/__init__.py +++ b/addons/hr_payroll_account/__init__.py @@ -21,5 +21,6 @@ ############################################################################## import hr_payroll_account +import wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/hr_payroll_account/hr_payroll_account.py b/addons/hr_payroll_account/hr_payroll_account.py index 6eb0a6d1859..8e4e73458f2 100644 --- a/addons/hr_payroll_account/hr_payroll_account.py +++ b/addons/hr_payroll_account/hr_payroll_account.py @@ -39,6 +39,13 @@ class hr_payslip(osv.osv): 'journal_id': fields.many2one('account.journal', 'Expense Journal',states={'draft': [('readonly', False)]}, readonly=True, required=True), 'move_id': fields.many2one('account.move', 'Accounting Entry', readonly=True), } + + def create(self, cr, uid, vals, context=None): + if context is None: + context = {} + if 'journal_id' in context: + vals.update({'journal_id': context.get('journal_id')}) + return super(hr_payslip, self).create(cr, uid, vals, context=context) def onchange_contract_id(self, cr, uid, ids, date_from, date_to, employee_id=False, contract_id=False, context=None): contract_obj = self.pool.get('hr.contract') diff --git a/addons/hr_payroll_account/wizard/__init__.py b/addons/hr_payroll_account/wizard/__init__.py new file mode 100644 index 00000000000..27128f05597 --- /dev/null +++ b/addons/hr_payroll_account/wizard/__init__.py @@ -0,0 +1,25 @@ +#-*- coding:utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# d$ +# +# 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 hr_payroll_payslips_by_employees + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/hr_payroll_account/wizard/hr_payroll_payslips_by_employees.py b/addons/hr_payroll_account/wizard/hr_payroll_payslips_by_employees.py new file mode 100644 index 00000000000..a00ff97ef6b --- /dev/null +++ b/addons/hr_payroll_account/wizard/hr_payroll_payslips_by_employees.py @@ -0,0 +1,40 @@ +# -*- 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 . +# +############################################################################## + +from osv import osv + +class hr_payslip_employees(osv.osv_memory): + + _inherit ='hr.payslip.employees' + + def compute_sheet(self, cr, uid, ids, context=None): + run_pool = self.pool.get('hr.payslip.run') + if context is None: + context = {} + if context and context.get('active_id', False): + run_data = run_pool.read(cr, uid, context['active_id'], ['journal_id']) + journal_id = run_data.get('journal_id', False)[0] + context.update({'journal_id': journal_id}) + return super(hr_payslip_employees, self).compute_sheet(cr, uid, ids, context=context) + +hr_payslip_employees() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file