Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

Changing Date for Payslip

By
salman
on 7/28/15, 4:49 AM 657 views

I have a problem in changing a date or an employee under hr.payslip after saving the record. it gives me the following error

ValueError: "name 'date_from' is not defined" while evaluating

'[date_from, date_to, employee_id, contract_id]'


Any advice

Can you give me your code please??

Drees Far
on 7/28/15, 4:58 AM

Ya Sure, this is actaully the function from a standard module i haven't made change on it. It raises the error when the following line is executed worked_days_obj.unlink(cr, uid, old_worked_days_ids, context=context) here is the function: def onchange_employee_id(self, cr, uid, ids, date_from, date_to, employee_id=False, contract_id=False, context=None): empolyee_obj = self.pool.get('hr.employee') contract_obj = self.pool.get('hr.contract') worked_days_obj = self.pool.get('hr.payslip.worked_days') input_obj = self.pool.get('hr.payslip.input') res = {'value':{ 'line_ids':[], 'input_line_ids': [], 'worked_days_line_ids': [], #'details_by_salary_head':[], TODO put me back 'name':'', 'contract_id': False, 'struct_id': False, } } if (not employee_id) or (not date_from) or (not date_to): return res if context is None: context = {} #delete old worked days lines old_worked_days_ids = ids and worked_days_obj.search(cr, uid, [('payslip_id', '=', ids[0])], context=context) or False if old_worked_days_ids: worked_days_obj.unlink(cr, uid, old_worked_days_ids, context=context) #return res #delete old input lines old_input_ids = ids and input_obj.search(cr, uid, [('payslip_id', '=', ids[0])], context=context) or False if old_input_ids: input_obj.unlink(cr, uid, old_input_ids, context=context) #defaults # res = {'value':{ # 'line_ids':[], # 'input_line_ids': [], # 'worked_days_line_ids': [], # #'details_by_salary_head':[], TODO put me back # 'name':'', # 'contract_id': False, # 'struct_id': False, # } # } # 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) res['value'].update({ 'name': _('Salary Slip of %s for %s') % (employee_id.name, tools.ustr(ttyme.strftime('%B-%Y'))), 'company_id': employee_id.company_id.id }) 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) else: if contract_id: #set the list of contract for which the input have to be filled contract_ids = [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 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) res['value'].update({ 'worked_days_line_ids': worked_days_line_ids, 'input_line_ids': input_line_ids, }) return res

salman
on 7/28/15, 5:05 AM
0
nishad
On 12/22/15, 5:11 AM

It will be ok if you comment/delete the following source code in hr_payroll/payslip.py/ function 

onchange_employee_id

-------------
#delete old worked days lines old_worked_days_ids = ids and worked_days_obj.search(cr, uid, [('payslip_id', '=', ids[0])], context=context) or False if old_worked_days_ids: worked_days_obj.unlink(cr, uid, old_worked_days_ids, context=context) #delete old input lines old_input_ids = ids and input_obj.search(cr, uid, [('payslip_id', '=', ids[0])], context=context) or False if old_input_ids: input_obj.unlink(cr, uid, old_input_ids, context=context)

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/28/15, 4:49 AM
Seen: 657 times
Last updated: 3/31/16, 3:13 AM