From 428259a2b6c4a1287c116220ad377b74e0b4c32d Mon Sep 17 00:00:00 2001 From: "Purnendu Singh (OpenERP)" Date: Fri, 14 Sep 2012 16:48:47 +0530 Subject: [PATCH 1/3] [IMP] hr_payroll: improve the onchange employee method on payslip so it will not give traceback in case contract is available for the selected employee and salary structure is not there bzr revid: psi@tinyerp.com-20120914111847-irocinmn1f29wc5d --- addons/hr_payroll/hr_payroll.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index c82c6db446b..4c6e4b20705 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -666,29 +666,30 @@ class hr_payslip(osv.osv): 'company_id': employee_id.company_id.id }) + struct_record = False if not context.get('contract', False): #fill with the first contract of the employee contract_ids = self.get_contract(cr, uid, employee_id, date_from, date_to, context=context) - res['value'].update({ - 'struct_id': contract_ids and contract_obj.read(cr, uid, contract_ids[0], ['struct_id'], context=context)['struct_id'][0] or False, - 'contract_id': contract_ids and contract_ids[0] or False, - }) else: if contract_id: #set the list of contract for which the input have to be filled contract_ids = [contract_id] - #fill the structure with the one on the selected contract - contract_record = contract_obj.browse(cr, uid, contract_id, context=context) - res['value'].update({ - 'struct_id': contract_record.struct_id.id, - 'contract_id': contract_id - }) else: #if we don't give the contract, then the input to fill should be for all current contracts of the employee contract_ids = self.get_contract(cr, uid, employee_id, date_from, date_to, context=context) - if not contract_ids: - return res + if not contract_ids: + return res + contract_record = contract_obj.browse(cr, uid, contract_ids[0], context=context) + res['value'].update({ + 'contract_id': contract_record and contract_record.id or False + }) + struct_record = contract_record and contract_record.struct_id or False + if not struct_record: + return res + res['value'].update({ + 'struct_id': struct_record.id, + }) #computation of the salary input worked_days_line_ids = self.get_worked_day_lines(cr, uid, contract_ids, date_from, date_to, context=context) input_line_ids = self.get_inputs(cr, uid, contract_ids, date_from, date_to, context=context) From d6608da3135645269d298335e22e431a01b5711d Mon Sep 17 00:00:00 2001 From: "Purnendu Singh (OpenERP)" Date: Fri, 14 Sep 2012 16:57:56 +0530 Subject: [PATCH 2/3] [FIX] hr_payroll: small fix in code bzr revid: psi@tinyerp.com-20120914112756-rbzvhcaj35sz5duk --- addons/hr_payroll/hr_payroll.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 4c6e4b20705..6a2e40b9571 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -666,7 +666,6 @@ class hr_payslip(osv.osv): 'company_id': employee_id.company_id.id }) - struct_record = False if not context.get('contract', False): #fill with the first contract of the employee contract_ids = self.get_contract(cr, uid, employee_id, date_from, date_to, context=context) From 45accdcb11448ddb43a5604b840d73fed5e82b62 Mon Sep 17 00:00:00 2001 From: Mayur Maheshwari <> Date: Fri, 14 Sep 2012 17:16:45 +0530 Subject: [PATCH 3/3] [FIX] hr_payroll: small fix in code bzr revid: psi@tinyerp.com-20120914114645-0nmbochejovtmxoa --- addons/hr_payroll/hr_payroll_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index 58484a91567..9d7da04208c 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -234,7 +234,7 @@ - +