This question has been flagged
1 Reply
2621 Views

Any one can help? In class "hr.employee" there is a one2many fields for "hr.payslip" w/c in turn has one2many fields for  "hr.payslip.line". My problem is whenever i output employee's payslips it return nothing but my database is populated.

Here is the chunk of my code:

for emp in self.pool.get('hr.employee').browse(cr,uid,emp_ids,context=context):
               pay_ids = self.pool.get('hr.payslip').search(cr,uid,[('employee_id','=',emp.id)],context=context)
               netsvc.Logger().notifyChannel("OUT PUT ", netsvc.LOG_INFO, 'EMP LIST ....' + str(emp_ids))
               netsvc.Logger().notifyChannel("OUT PUT ", netsvc.LOG_INFO, 'PAYSLIP :::::' + str(pay_ids))
*** pay_ids shows nothing but an empty list ***
anyone can help?

 

Avatar
Discard
Best Answer

Are you sure emp_ids is not an empty list? 

Furthermore, what is the result when you approach from the other way around, i.e. browse over all the hr.payslip records with no domain? Do you get any result?

So (pseudocode):

pay_slip_obj = self.pool.get('hr.payslip')

pay_ids = pay_slip_obj.search(cr, uid, [])

for rec in pay_slip_obj.browse(cr, uid, pay_ids):

    print "Rec emp ==> ", rec.employee_id.id

Avatar
Discard
Author

Well said sir, the emp ids returns a list of employees and base on netsvc.Logger().notifyChannel("OUT PUT ", netsvc.LOG_INFO, 'EMP LIST ....' + str(emp_ids)) it output an employee list.

Author

by the way sir, here is my emp_ids: emp_ids = self.pool.get('hr.employee').search(cr,uid,[('id','!=',0)])

Were you able to solve this after all? By the way, to get all the active employees from a search, you do not need 'id','!=',0. This is automatically included. Just use [] (empty list) in your domain to get all the records.

Author

Nope, i was not able to solve because pay_ids still output an empty list and yeah i tried to use an empty domain and still i retrieved all employee.