From d4950bdbd8fa133ff5b9afd4ef8edb3188a1d12a Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 11 Apr 2011 14:10:07 +0530 Subject: [PATCH 1/9] [IMP] Payroll: put back the tab with rules grouped by head bzr revid: mra@mra-laptop-20110411084007-g5p3gvdcl7z9uh2m --- addons/hr_payroll/hr_payroll.py | 61 ++++++++++++--------------- addons/hr_payroll/hr_payroll_view.xml | 8 ++-- 2 files changed, 32 insertions(+), 37 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 831029f7aff..297bfa6b040 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -185,37 +185,32 @@ class hr_payslip(osv.osv): _name = 'hr.payslip' _description = 'Pay Slip' -#TODO unused for now, cause the field is commented but we want to put it back -# def _get_salary_rules(self, cr, uid, ids, field_names, arg=None, context=None): -# structure_obj = self.pool.get('hr.payroll.structure') -# contract_obj = self.pool.get('hr.contract') -# res = {} -# rules = [] -# contracts = [] -# structures = [] -# rule_ids = [] -# sorted_salary_heads = [] -# for record in self.browse(cr, uid, ids, context=context): -# if record.contract_id: -# contracts.append(record.contract_id.id) -# else: -# contracts = self.get_contract(cr, uid, record.employee_id, record.date, context=context) -# for contract in contracts: -# structures = contract_obj.get_all_structures(cr, uid, [contract], context) -# res[record.id] = {} -# for struct in structures: -# rule_ids = structure_obj.get_all_rules(cr, uid, [struct], context=None) -# for rl in rule_ids: -# if rl[0] not in rules: -# rules.append(rl[0]) -# cr.execute('''SELECT sr.id FROM hr_salary_rule as sr, hr_salary_head as sh -# WHERE sr.category_id = sh.id AND sr.id in %s ORDER BY sh.sequence''',(tuple(rules),)) -# for x in cr.fetchall(): -# sorted_salary_heads.append(x[0]) -# for fn in field_names: -# if fn == 'details_by_salary_head': -# res[record.id] = {fn: sorted_salary_heads} -# return res + def move_line_id_payment_gets(self, cr, uid, ids, *args): + res = {} + if not ids: return res + cr.execute('SELECT i.id, l.id '\ + 'FROM account_move_line l '\ + 'LEFT JOIN account_invoice i ON (i.move_id=l.move_id) '\ + 'WHERE i.id IN %s '\ + 'AND l.account_id=i.account_id', + (tuple(ids),)) + for r in cr.fetchall(): + res.setdefault(r[0], []) + res[r[0]].append( r[1] ) + return res + + def _get_lines_salary_head(self, cr, uid, ids, field_names, arg=None, context=None): + result = {} + if not ids: return result + 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 _columns = { 'struct_id': fields.many2one('hr.payroll.structure', 'Structure', help='Defines the rules that have to be applied to this payslip, accordingly to the contract chosen. If you let empty the field contract, this field isn\'t mandatory anymore and thus the rules applied will be all the rules set on the structure of all contracts of the employee valid for the chosen period'), @@ -244,8 +239,7 @@ class hr_payslip(osv.osv): 'paid': fields.boolean('Made Payment Order ? ', required=False, readonly=True, states={'draft': [('readonly', False)]}), 'note': fields.text('Description'), 'contract_id': fields.many2one('hr.contract', 'Contract', required=False, readonly=True, states={'draft': [('readonly', False)]}), - #TODO put me back - # 'details_by_salary_head': fields.function(_get_salary_rules, method=True, type='one2many', relation='hr.salary.rule', string='Details by Salary Head', multi='details_by_salary_head'), + 'details_by_salary_head': fields.function(_get_lines_salary_head, method=True, type='one2many', relation='hr.payslip.line', string='Details by Salary Head'), } _defaults = { 'date_from': lambda *a: time.strftime('%Y-%m-01'), @@ -491,6 +485,7 @@ class hr_payslip(osv.osv): 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)] + return result def onchange_employee_id(self, cr, uid, ids, date_from, date_to, employee_id=False, contract_id=False, context=None): diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index 3df7433a44e..8c4929e7713 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -236,17 +236,17 @@ - + From dd68253b95e6c28f7176431d4598e2e0e64af923 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 11 Apr 2011 16:05:27 +0530 Subject: [PATCH 2/9] [IMP] payroll: new structure should get as default for parent_id: ref(structure_base) bzr revid: mra@mra-laptop-20110411103527-7zza1n093a27ohhu --- addons/hr_payroll/hr_payroll.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index a0830eb6b58..d9c927fa579 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -51,10 +51,17 @@ class hr_payroll_structure(osv.osv): 'note': fields.text('Description'), 'parent_id':fields.many2one('hr.payroll.structure', 'Parent'), } + + def _get_parent(self, cr, uid, context=None): + data_id = self.pool.get('ir.model.data').search(cr, uid, [('model', '=', 'hr.payroll.structure'), ('name', '=', 'structure_base')]) + res = self.pool.get('ir.model.data').browse(cr, uid, data_id[0], context=context).res_id + return res or False + _defaults = { 'company_id': lambda self, cr, uid, context: \ self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id, + 'parent_id': _get_parent, } def copy(self, cr, uid, id, default=None, context=None): From 295f699558644a496b674932fde3e264282ed60a Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 11 Apr 2011 16:14:37 +0530 Subject: [PATCH 3/9] [REM] unused code bzr revid: mra@mra-laptop-20110411104437-08y014kaeelpw150 --- addons/hr_payroll/hr_payroll.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 297bfa6b040..44c0b365c7a 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -185,20 +185,6 @@ class hr_payslip(osv.osv): _name = 'hr.payslip' _description = 'Pay Slip' - def move_line_id_payment_gets(self, cr, uid, ids, *args): - res = {} - if not ids: return res - cr.execute('SELECT i.id, l.id '\ - 'FROM account_move_line l '\ - 'LEFT JOIN account_invoice i ON (i.move_id=l.move_id) '\ - 'WHERE i.id IN %s '\ - 'AND l.account_id=i.account_id', - (tuple(ids),)) - for r in cr.fetchall(): - res.setdefault(r[0], []) - res[r[0]].append( r[1] ) - return res - def _get_lines_salary_head(self, cr, uid, ids, field_names, arg=None, context=None): result = {} if not ids: return result From 81a66b9d3975d15a3578efaab64d76ae2b637682 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 11 Apr 2011 17:06:37 +0530 Subject: [PATCH 4/9] [FIX] payroll: grouping of details by salayr head AND domain is not applied on first tab of payslip, we should see there only the payslip lines with appears_on_payslip = True bzr revid: mra@mra-laptop-20110411113637-qfnxuylu1icn6889 --- addons/hr_payroll/hr_payroll.py | 2 +- addons/hr_payroll/hr_payroll_view.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 44c0b365c7a..7a59a3fd93a 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -352,7 +352,7 @@ class hr_payslip(osv.osv): else: #if we don't give the contract, then the rules to apply should be for all current contracts of the employee contract_ids = self.get_contract(cr, uid, payslip.employee_id, payslip.date_from, payslip.date_to, context=context) - lines = [(0,0,line) for line in self.pool.get('hr.payslip').get_payslip_lines(cr, uid, contract_ids, payslip.id, context=context)] + lines = [(0,0,line) for line in self.pool.get('hr.payslip').get_payslip_lines(cr, uid, contract_ids, payslip.id, context=context) if line['appears_on_payslip']] self.write(cr, uid, [payslip.id], {'line_ids': lines}, context=context) return True diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index 8c4929e7713..73d5b11ac88 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -237,7 +237,7 @@ - + From d43364223251bcbc920c314270772c3fd29c48b7 Mon Sep 17 00:00:00 2001 From: mtr Date: Mon, 11 Apr 2011 17:28:23 +0530 Subject: [PATCH 5/9] [IMP] hr_payroll: added access rules bzr revid: mtr@mtr-20110411115823-kp0oarpmo8vz9rtr --- addons/hr_payroll/security/ir.model.access.csv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/hr_payroll/security/ir.model.access.csv b/addons/hr_payroll/security/ir.model.access.csv index 557633b3d86..431ae06fa20 100644 --- a/addons/hr_payroll/security/ir.model.access.csv +++ b/addons/hr_payroll/security/ir.model.access.csv @@ -8,3 +8,5 @@ "access_hr_payslip_manager","hr.payslip.manager","model_hr_payslip","base.group_hr_manager",1,1,1,1 "access_hr_payslip_line_manager","hr.payslip.line.manager","model_hr_payslip_line","base.group_hr_manager",1,1,1,1 "access_hr_payroll_structure_manager","hr.payroll.structure.manager","model_hr_payroll_structure","base.group_hr_manager",1,1,1,1 +"access_hr_payslip_input ","hr.payslip.input","model_hr_payslip_input","base.group_hr_manager",1,1,1,1 +"access_hr_salary_rule","hr.salary.rule","model_hr_salary_rule","base.group_hr_manager",1,1,1,1 From c4a1c85e4129133591118ea87949bfc438bc6dc9 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 11 Apr 2011 17:42:41 +0530 Subject: [PATCH 6/9] [REM] payroll: remove the if condition from payslip lines appears bzr revid: mra@mra-laptop-20110411121241-eh69dw6hq2bu8smb --- addons/hr_payroll/hr_payroll.py | 2 +- addons/hr_payroll/hr_payroll_view.xml | 2 +- addons/hr_payroll/security/ir.model.access.csv | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index b9f609516df..5937bb7d67e 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -386,7 +386,7 @@ class hr_payslip(osv.osv): else: #if we don't give the contract, then the rules to apply should be for all current contracts of the employee contract_ids = self.get_contract(cr, uid, payslip.employee_id, payslip.date_from, payslip.date_to, context=context) - lines = [(0,0,line) for line in self.pool.get('hr.payslip').get_payslip_lines(cr, uid, contract_ids, payslip.id, context=context) if line['appears_on_payslip']] + lines = [(0,0,line) for line in self.pool.get('hr.payslip').get_payslip_lines(cr, uid, contract_ids, payslip.id, context=context)] self.write(cr, uid, [payslip.id], {'line_ids': lines}, context=context) return True diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index 6abf4edaa9e..44fc0d595de 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -237,7 +237,7 @@ - + diff --git a/addons/hr_payroll/security/ir.model.access.csv b/addons/hr_payroll/security/ir.model.access.csv index 557633b3d86..d8238cc02cc 100644 --- a/addons/hr_payroll/security/ir.model.access.csv +++ b/addons/hr_payroll/security/ir.model.access.csv @@ -8,3 +8,5 @@ "access_hr_payslip_manager","hr.payslip.manager","model_hr_payslip","base.group_hr_manager",1,1,1,1 "access_hr_payslip_line_manager","hr.payslip.line.manager","model_hr_payslip_line","base.group_hr_manager",1,1,1,1 "access_hr_payroll_structure_manager","hr.payroll.structure.manager","model_hr_payroll_structure","base.group_hr_manager",1,1,1,1 +"access_hr_payslip_input ","hr.payslip.input.user","model_hr_payslip_input","base.group_hr_user",1,1,1,1 +"access_hr_salary_rule","hr.salary.rule","model_hr_salary_rule","base.group_hr_user",1,1,1,1 From c976c757d88d1dffa3b00f61f10bead1d1144fab Mon Sep 17 00:00:00 2001 From: "Quentin (OpenERP)" Date: Mon, 11 Apr 2011 17:47:15 +0200 Subject: [PATCH 7/9] [IMP] hr_payroll: added head data for company contribution bzr revid: qdp-launchpad@openerp.com-20110411154715-idvt0myzjnurmlj2 --- addons/hr_payroll/hr_payroll_data.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/hr_payroll/hr_payroll_data.xml b/addons/hr_payroll/hr_payroll_data.xml index df21b9ea61a..21273bfa725 100644 --- a/addons/hr_payroll/hr_payroll_data.xml +++ b/addons/hr_payroll/hr_payroll_data.xml @@ -27,6 +27,11 @@ NET + + Company Contribution + COMP + + @@ -68,7 +68,7 @@ - + MEQP Marketing Executive for Quentin Paolino @@ -99,7 +99,7 @@ - + Contract For Quentin Paolino