diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 080b0dede20..8b1987ec058 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -646,7 +646,7 @@ class hr_payslip(osv.osv): 'struct_id': False, } } - if not employee_id: + if (not employee_id) or (not date_from) or (not date_to): return res ttyme = datetime.fromtimestamp(time.mktime(time.strptime(date_from, "%Y-%m-%d"))) employee_id = empolyee_obj.browse(cr, uid, employee_id, context=context) diff --git a/addons/hr_payroll/test/payslip.yml b/addons/hr_payroll/test/payslip.yml index 09af98ee0cd..94c38b263fc 100644 --- a/addons/hr_payroll/test/payslip.yml +++ b/addons/hr_payroll/test/payslip.yml @@ -40,25 +40,6 @@ - !record {model: hr.payslip, id: hr_payslip_0}: employee_id: hr_payroll.hr_employee_richard0 -- - The selection of an employee fills the contract, structure, worked days and input data fields -- - !python {model: hr.payslip}: | - import time - from datetime import datetime - from dateutil import relativedelta - date_from = time.strftime('%Y-%m-01') - worked_days_obj = self.pool.get('hr.payslip.worked_days') - date_to = str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10] - res = self.onchange_employee_id(cr, uid, [], date_from, date_to, ref("hr_employee_richard0"), False, None) - vals = { - 'struct_id': res['value']['struct_id'], - 'contract_id': res['value']['contract_id'], - 'name': res['value']['name'], - } - vals['worked_days_line_ids'] = [(0,0,i) for i in res['value']['worked_days_line_ids']] - vals['input_line_ids'] = [(0, 0, i) for i in res['value']['input_line_ids']] - self.write(cr, uid, ref("hr_payslip_0"), vals) - I assign the amount to Input data - @@ -69,9 +50,8 @@ I verify the payslip is in draft state - !python {model: hr.payslip}: | - from tools.translate import _ payslip_brw=self.browse(cr, uid, ref("hr_payslip_0")) - assert(payslip_brw.state == 'draft'), _('State not changed!') + assert (payslip_brw.state == 'draft'), 'State not changed!' - I click on 'Compute Sheet' button on payslip -