diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index c82c6db446b..6a2e40b9571 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -669,26 +669,26 @@ class hr_payslip(osv.osv): 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) diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index d6df0e0332e..ef3c0ea2e9f 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -234,7 +234,7 @@ - +