From d6dd4198ea15355d86861a8e1ece72255fb841d7 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 25 Apr 2011 12:49:30 +0530 Subject: [PATCH 01/37] [IMP] Payroll: to ease the use of the engine, we should use the code of rule directly as variable name instead of rules[] (we keep as it for heads[]). So it means that i should be able to use 'gross' instead of rules['gross'] bzr revid: mra@mra-laptop-20110425071930-co05h4pyl0k73a4v --- addons/hr_payroll/hr_payroll.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 6757b57c417..8306d1f9fb9 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -482,11 +482,12 @@ class hr_payslip(osv.osv): #we keep a dict with the result because a value can be overwritten by another rule with the same code result_dict = {} blacklist = [] + obj_rule = self.pool.get('hr.salary.rule') payslip = self.pool.get('hr.payslip').browse(cr, uid, payslip_id, context=context) worked_days = {} for input_line in payslip.input_line_ids: worked_days[input_line.code] = input_line - localdict = {'rules': {}, 'heads': {}, 'payslip': payslip, 'worked_days': worked_days} + localdict = {'heads': {}, 'payslip': payslip, 'worked_days': worked_days} #get the ids of the structures on the contracts and their parent id as well structure_ids = self.pool.get('hr.contract').get_all_structures(cr, uid, contract_ids, context=context) #get the rules of the structure and thier children @@ -497,17 +498,17 @@ class hr_payslip(osv.osv): for contract in self.pool.get('hr.contract').browse(cr, uid, contract_ids, context=context): employee = contract.employee_id localdict.update({'employee': employee, 'contract': contract}) - for rule in self.pool.get('hr.salary.rule').browse(cr, uid, sorted_rule_ids, context=context): + for rule in obj_rule.browse(cr, uid, sorted_rule_ids, context=context): key = rule.code + '-' + str(contract.id) localdict['result'] = None #check if the rule can be applied - if self.pool.get('hr.salary.rule').satisfy_condition(cr, uid, rule.id, localdict, context=context) and rule.id not in blacklist: + if obj_rule.satisfy_condition(cr, uid, rule.id, localdict, context=context) and rule.id not in blacklist: #compute the amount of the rule - amount = self.pool.get('hr.salary.rule').compute_rule(cr, uid, rule.id, localdict, context=context) + amount = obj_rule.compute_rule(cr, uid, rule.id, localdict, context=context) #check if there is already a rule computed with that code - previous_amount = rule.code in localdict['rules'] and localdict['rules'][rule.code] or 0.0 + previous_amount = rule.code in localdict and localdict[rule.code] or 0.0 #set/overwrite the amount computed for this rule in the localdict - localdict['rules'][rule.code] = amount + localdict[rule.code] = amount #sum the amount for its salary head localdict = _sum_salary_head(localdict, rule.category_id, amount - previous_amount) #create/overwrite the rule in the temporary results @@ -679,7 +680,7 @@ class hr_salary_rule(osv.osv): # payslip: hr.payslip object # employee: hr.employee object # contract: hr.contract object -# rules: dictionary containing the previsouly computed rules. Keys are the rule codes. +# rules: rules code (previously computed) # heads: dictionary containing the computed heads (sum of amount of all rules belonging to that head). Keys are the head codes. # worked_days: dictionary containing the computed worked days. Keys are the worked days codes. @@ -693,7 +694,7 @@ result = contract.wage * 0.10''', # payslip: hr.payslip object # employee: hr.employee object # contract: hr.contract object -# rules: dictionary containing the previsouly computed rules. Keys are the rule codes. +# rules: rules code (previously computed) # heads: dictionary containing the computed heads (sum of amount of all rules belonging to that head). Keys are the head codes. # worked_days: dictionary containing the computed worked days. Keys are the worked days codes. From 51543fa458bfcdf8d702596aa44c90d78b0b8eb9 Mon Sep 17 00:00:00 2001 From: mtr Date: Mon, 25 Apr 2011 12:55:10 +0530 Subject: [PATCH 02/37] [IMP] hr_payroll:added field 'quantity' on salary rules,modified computation engine and demo data bzr revid: mtr@mtr-20110425072510-9f7tbuo9w3q3qq30 --- addons/hr_payroll/hr_payroll.py | 13 +++++++++++-- addons/hr_payroll/hr_payroll_demo.xml | 10 ++++++++-- addons/hr_payroll/hr_payroll_view.xml | 3 ++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 6757b57c417..b3434293342 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -500,6 +500,7 @@ class hr_payslip(osv.osv): for rule in self.pool.get('hr.salary.rule').browse(cr, uid, sorted_rule_ids, context=context): key = rule.code + '-' + str(contract.id) localdict['result'] = None + localdict.update({'quantity': rule.quantity or None}) #check if the rule can be applied if self.pool.get('hr.salary.rule').satisfy_condition(cr, uid, rule.id, localdict, context=context) and rule.id not in blacklist: #compute the amount of the rule @@ -532,10 +533,12 @@ class hr_payslip(osv.osv): 'register_id': rule.register_id.id, 'total': amount, 'employee_id': contract.employee_id.id, + 'quantity': rule.quantity, } else: #blacklist this rule and its children blacklist += [id for id, seq in self.pool.get('hr.salary.rule')._recursive_search_of_rules(cr, uid, [rule], context=context)] + result = [value for code, value in result_dict.items()] return result @@ -640,6 +643,7 @@ class hr_salary_rule(osv.osv): 'name':fields.char('Name', size=256, required=True, readonly=False), 'code':fields.char('Code', size=64, required=True), 'sequence': fields.integer('Sequence', required=True, help='Use to arrange calculation sequence'), + 'quantity': fields.char('Quantity', size=256), 'category_id':fields.many2one('hr.salary.head', 'Salary Head', required=True), 'active':fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the salary rule without removing it."), 'appears_on_payslip': fields.boolean('Appears on Payslip', help="Used for the display of rule on payslip"), @@ -711,6 +715,7 @@ result = rules['NET'] > heads['NET'] * 0.10''', 'amount_select': 'fix', 'amount_fix': 0.0, 'amount_percentage': 0.0, + 'quantity': 1, } def _recursive_search_of_rules(self, cr, uid, rule_ids, context=None): @@ -733,10 +738,14 @@ result = rules['NET'] > heads['NET'] * 0.10''', """ rule = self.browse(cr, uid, rule_id, context=context) if rule.amount_select == 'fix': - return rule.amount_fix + try: + return rule.amount_fix * eval(rule.quantity, localdict) + except: + raise osv.except_osv(_('Error'), _('Wrong quantity defined for salary rule %s (%s)')% (rule.name, rule.code)) elif rule.amount_select == 'percentage': try: - return rule.amount_percentage * eval(rule.amount_percentage_base, localdict) / 100 + amount = rule.amount_percentage * eval(rule.amount_percentage_base, localdict) / 100 + return amount * eval(rule.quantity, localdict) except: raise osv.except_osv(_('Error'), _('Wrong percentage base defined for salary rule %s (%s)')% (rule.name, rule.code)) else: diff --git a/addons/hr_payroll/hr_payroll_demo.xml b/addons/hr_payroll/hr_payroll_demo.xml index 24736cbb9c2..c90cde78b94 100644 --- a/addons/hr_payroll/hr_payroll_demo.xml +++ b/addons/hr_payroll/hr_payroll_demo.xml @@ -12,6 +12,7 @@ House Rent Allowance + 1 @@ -21,6 +22,7 @@ Conveyance Allowance + 1 @@ -30,6 +32,7 @@ PT Professional Tax + 1 @@ -40,6 +43,7 @@ PF Provident Fund + 1 @@ -49,11 +53,13 @@ Conveyance Allowance For Paolino + 1 - code - result = worked_days['WORK100']['number_of_days'] * 1 + fix + + worked_days['WORK100']['number_of_days'] MA Meal Voucher diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index e1efc9d7f0c..8aae0d37046 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -546,7 +546,8 @@ - + + From 9f2709ccd0e9418594a6f3377fa9f0e0c93988bc Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Mon, 25 Apr 2011 15:11:42 +0530 Subject: [PATCH 03/37] [FIX] hr_payroll: payslip line color is blue when total is 0 bzr revid: ara@tinyerp.com-20110425094142-w0hjdx79bq84r920 --- addons/hr_payroll/hr_payroll_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index e1efc9d7f0c..8e491874944 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -135,7 +135,7 @@ hr.payslip.line tree - + @@ -242,7 +242,7 @@ - + From 3c877bb4c78b01803c7a079b6bab81e8a6ae0bb8 Mon Sep 17 00:00:00 2001 From: mtr Date: Mon, 25 Apr 2011 15:25:37 +0530 Subject: [PATCH 04/37] [IMP] hr_payroll:removed qty from demo,improved search engine,made qty mandatory and added tooltip bzr revid: mtr@mtr-20110425095537-ewmhlikkh5i50jyg --- addons/hr_payroll/hr_payroll.py | 5 ++--- addons/hr_payroll/hr_payroll_demo.xml | 5 ----- addons/hr_payroll/hr_payroll_view.xml | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index b3434293342..57fbe2df201 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -500,7 +500,6 @@ class hr_payslip(osv.osv): for rule in self.pool.get('hr.salary.rule').browse(cr, uid, sorted_rule_ids, context=context): key = rule.code + '-' + str(contract.id) localdict['result'] = None - localdict.update({'quantity': rule.quantity or None}) #check if the rule can be applied if self.pool.get('hr.salary.rule').satisfy_condition(cr, uid, rule.id, localdict, context=context) and rule.id not in blacklist: #compute the amount of the rule @@ -643,7 +642,7 @@ class hr_salary_rule(osv.osv): 'name':fields.char('Name', size=256, required=True, readonly=False), 'code':fields.char('Code', size=64, required=True), 'sequence': fields.integer('Sequence', required=True, help='Use to arrange calculation sequence'), - 'quantity': fields.char('Quantity', size=256), + 'quantity': fields.char('Quantity', size=256, help="It is used in computation for percentage and fixed amount.For e.g. A rule for Meal Voucher having fixed amount of 1€ can have its quantity defined in expression like worked_days['WORK100']['number_of_days']."), 'category_id':fields.many2one('hr.salary.head', 'Salary Head', required=True), 'active':fields.boolean('Active', help="If the active field is set to false, it will allow you to hide the salary rule without removing it."), 'appears_on_payslip': fields.boolean('Appears on Payslip', help="Used for the display of rule on payslip"), @@ -715,7 +714,7 @@ result = rules['NET'] > heads['NET'] * 0.10''', 'amount_select': 'fix', 'amount_fix': 0.0, 'amount_percentage': 0.0, - 'quantity': 1, + 'quantity': '1', } def _recursive_search_of_rules(self, cr, uid, rule_ids, context=None): diff --git a/addons/hr_payroll/hr_payroll_demo.xml b/addons/hr_payroll/hr_payroll_demo.xml index c90cde78b94..db903fbabfe 100644 --- a/addons/hr_payroll/hr_payroll_demo.xml +++ b/addons/hr_payroll/hr_payroll_demo.xml @@ -12,7 +12,6 @@ House Rent Allowance - 1 @@ -22,7 +21,6 @@ Conveyance Allowance - 1 @@ -32,7 +30,6 @@ PT Professional Tax - 1 @@ -43,7 +40,6 @@ PF Provident Fund - 1 @@ -53,7 +49,6 @@ Conveyance Allowance For Paolino - 1 diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index 8aae0d37046..6c0f615e3e7 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -547,7 +547,7 @@ - + From 122d51a2d7b49a02804925b99704d9427e8f2f8a Mon Sep 17 00:00:00 2001 From: mtr Date: Mon, 25 Apr 2011 15:55:02 +0530 Subject: [PATCH 05/37] [IMP] hr_payroll:improved exception message string bzr revid: mtr@mtr-20110425102502-6basvgqilrh664th --- addons/hr_payroll/hr_payroll.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 57fbe2df201..ecfc417c90e 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -746,7 +746,7 @@ result = rules['NET'] > heads['NET'] * 0.10''', amount = rule.amount_percentage * eval(rule.amount_percentage_base, localdict) / 100 return amount * eval(rule.quantity, localdict) except: - raise osv.except_osv(_('Error'), _('Wrong percentage base defined for salary rule %s (%s)')% (rule.name, rule.code)) + raise osv.except_osv(_('Error'), _('Wrong percentage base/quantity defined for salary rule %s (%s)')% (rule.name, rule.code)) else: try: eval(rule.amount_python_compute, localdict, mode='exec', nocopy=True) From 11da3fc37b3bdedff6da103af525fcc3562ded95 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Mon, 25 Apr 2011 15:55:44 +0530 Subject: [PATCH 06/37] [FIX] hr_payroll: payslip line color is blue when total is 0 bzr revid: ara@tinyerp.com-20110425102544-ivqy6vu4fb14z68u --- addons/hr_payroll/hr_payroll_view.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index 8e491874944..2f542999b43 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -144,6 +144,7 @@ + @@ -280,7 +281,7 @@ - + From eac6fb073cba5194dca4483e77897f1cd3a4fd25 Mon Sep 17 00:00:00 2001 From: mtr Date: Mon, 25 Apr 2011 16:07:18 +0530 Subject: [PATCH 07/37] [IMP] hr_payroll:improved payslip line view,removed fields that are used to calculate the total bzr revid: mtr@mtr-20110425103718-r80y25vatlik17z4 --- addons/hr_payroll/hr_payroll_view.xml | 31 ++++++--------------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index e1efc9d7f0c..f3be5ffda11 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -250,30 +250,13 @@
- - - - - + + + + + + - - - - - - - - - - - - - - - - - -
@@ -291,7 +274,7 @@ - + From 30564f93e9fffe2dfaed90743229ed6ac142dbe7 Mon Sep 17 00:00:00 2001 From: mtr Date: Mon, 25 Apr 2011 17:34:30 +0530 Subject: [PATCH 08/37] [IMP] hr_payroll:again improved exception message string bzr revid: mtr@mtr-20110425120430-kacidzhufm6n25q7 --- addons/hr_payroll/hr_payroll.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index ecfc417c90e..27de59c8f71 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -746,7 +746,7 @@ result = rules['NET'] > heads['NET'] * 0.10''', amount = rule.amount_percentage * eval(rule.amount_percentage_base, localdict) / 100 return amount * eval(rule.quantity, localdict) except: - raise osv.except_osv(_('Error'), _('Wrong percentage base/quantity defined for salary rule %s (%s)')% (rule.name, rule.code)) + raise osv.except_osv(_('Error'), _('Wrong percentage base or quantity defined for salary rule %s (%s)')% (rule.name, rule.code)) else: try: eval(rule.amount_python_compute, localdict, mode='exec', nocopy=True) From ea9ab772d62392cff972773fc1bdf46e9d85138c Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Mon, 25 Apr 2011 18:00:44 +0530 Subject: [PATCH 09/37] [IMP] Add wizard to generate payslip by employee categories bzr revid: psi@tinyerp.co.in-20110425123044-hxb20cq7iynw5ou7 --- addons/hr_payroll/__openerp__.py | 1 + addons/hr_payroll/hr_payroll.py | 13 ++++- addons/hr_payroll/hr_payroll_view.xml | 44 ++++++++++++-- addons/hr_payroll/wizard/__init__.py | 4 +- .../wizard/hr_payroll_payslips_by_category.py | 58 +++++++++++++++++++ .../hr_payroll_payslips_by_category.xml | 45 ++++++++++++++ 6 files changed, 156 insertions(+), 9 deletions(-) create mode 100644 addons/hr_payroll/wizard/hr_payroll_payslips_by_category.py create mode 100644 addons/hr_payroll/wizard/hr_payroll_payslips_by_category.xml diff --git a/addons/hr_payroll/__openerp__.py b/addons/hr_payroll/__openerp__.py index 87fe437a1db..822573db480 100644 --- a/addons/hr_payroll/__openerp__.py +++ b/addons/hr_payroll/__openerp__.py @@ -57,6 +57,7 @@ Generic Payroll system. 'security/ir.model.access.csv', 'wizard/hr_payroll_employees_detail.xml', 'wizard/hr_payroll_year_salary.xml', + 'wizard/hr_payroll_payslips_by_category.xml', ], 'test': [ # 'test/payslip.yml', diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 6757b57c417..55ec3d7995a 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -204,6 +204,15 @@ class one2many_mod2(fields.one2many): res[r[self._fields_id]].append( r['id'] ) return res +class hr_payslip_groups(osv.osv): + + _name = 'hr.payslip.groups' + _columns = { + 'name':fields.char('Name', size=256, required=True), + 'slip_ids':fields.one2many('hr.payslip', 'payslip_group_id', 'Payslips', required=False, readonly=True), + } +hr_payslip_groups() + class hr_payslip(osv.osv): ''' Pay Slip @@ -215,13 +224,14 @@ class hr_payslip(osv.osv): def _get_lines_salary_head(self, cr, uid, ids, field_names, arg=None, context=None): result = {} if not ids: return result + for id in ids: + result.setdefault(id, []) cr.execute('''SELECT pl.slip_id, pl.id FROM hr_payslip_line AS pl \ LEFT JOIN hr_salary_head AS sh on (pl.category_id = sh.id) \ WHERE pl.slip_id in %s \ GROUP BY pl.slip_id, sh.sequence, pl.sequence, pl.id ORDER BY sh.sequence, pl.sequence''',(tuple(ids),)) res = cr.fetchall() for r in res: - result.setdefault(r[0], []) result[r[0]].append(r[1]) return result @@ -255,6 +265,7 @@ class hr_payslip(osv.osv): 'contract_id': fields.many2one('hr.contract', 'Contract', required=False, readonly=True, states={'draft': [('readonly', False)]}), 'details_by_salary_head': fields.function(_get_lines_salary_head, method=True, type='one2many', relation='hr.payslip.line', string='Details by Salary Head'), 'credit_note': fields.boolean('Credit Note', help="Indicates this payslip has a refund of another"), + 'payslip_group_id': fields.many2one('hr.payslip.groups', 'Group', readonly=True, states={'draft': [('readonly', False)]}), } _defaults = { 'date_from': lambda *a: time.strftime('%Y-%m-01'), diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index e1efc9d7f0c..e319b209011 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -188,8 +188,8 @@ - - + + @@ -211,7 +211,7 @@ hr.payslip tree - + @@ -278,7 +278,7 @@ - + @@ -549,14 +549,14 @@ - + - + @@ -601,6 +601,38 @@ + + hr.payslip.category.tree + hr.payslip.groups + tree + + + + + + + + + hr.payslip.category.form + hr.payslip.groups + form + +
+ + + + + +
+
+ + + Payslips by Category + hr.payslip.groups + form + + + diff --git a/addons/hr_payroll/wizard/__init__.py b/addons/hr_payroll/wizard/__init__.py index 2cf78e17b1c..fc8083099a5 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 (). All Rights Reserved # d$ # @@ -24,5 +24,5 @@ import hr_payroll_employees_detail #import hr_payroll_create_analytic import hr_payroll_year_salary - +import hr_payroll_payslips_by_category # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/hr_payroll/wizard/hr_payroll_payslips_by_category.py b/addons/hr_payroll/wizard/hr_payroll_payslips_by_category.py new file mode 100644 index 00000000000..9f8d9c010f9 --- /dev/null +++ b/addons/hr_payroll/wizard/hr_payroll_payslips_by_category.py @@ -0,0 +1,58 @@ +# -*- 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 fields, osv +import netsvc + +class hr_payroll_payslip_groups(osv.osv_memory): + + _name ='hr.payroll.payslip.groups' + _columns = { + 'employee_category': fields.many2one('hr.employee.category', 'Employee Category', required=True), + } + + def compute_sheet(self, cr, uid, ids, context=None): + emp_pool = self.pool.get('hr.employee') + slip_pool = self.pool.get('hr.payslip') + wf_service = netsvc.LocalService("workflow") + if context is None: + context = {} + data = self.read(cr, uid, ids, context=context)[0] + cr.execute('SELECT DISTINCT emp_id FROM employee_category_rel WHERE category_id = %s', (data['employee_category'][0], )) + emp_ids = filter(None, map(lambda x:x[0], cr.fetchall())) + for emp in emp_pool.browse(cr, uid, emp_ids, context=context): + old_slips = slip_pool.search(cr, uid, [('employee_id','=', emp.id)], context=context) + if old_slips: + slip_pool.write(cr, uid, old_slips, {'payslip_group_id': context.get('active_id', False)}, context=context) + for sid in old_slips: + wf_service.trg_validate(uid, 'hr.payslip', sid, 'compute_sheet', cr) + else: + res = { + 'employee_id': emp.id, + 'payslip_group_id': context.get('active_id', False), + } + slip_id = slip_pool.create(cr, uid, res, context=context) + wf_service.trg_validate(uid, 'hr.payslip', slip_id, 'compute_sheet', cr) + return {'type': 'ir.actions.act_window_close'} + +hr_payroll_payslip_groups() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll/wizard/hr_payroll_payslips_by_category.xml b/addons/hr_payroll/wizard/hr_payroll_payslips_by_category.xml new file mode 100644 index 00000000000..394a894c024 --- /dev/null +++ b/addons/hr_payroll/wizard/hr_payroll_payslips_by_category.xml @@ -0,0 +1,45 @@ + + + + + + hr_payroll_payslip_category + hr.payroll.payslip.groups + form + +
+ + + + + + +