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.

2

Why do one2many fields return empty list?

By
Anirudh Lou
on 10/8/14, 4:04 AM 518 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?

 

1

Ludo - Neobis

--Ludo - Neobis--
2387
| 2 2 5
Hoogvliet, Netherlands
--Ludo - Neobis--

Developer

Ludo - Neobis
On 10/8/14, 4:35 AM

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

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.

Anirudh Lou
on 10/8/14, 4:43 AM

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

Anirudh Lou
on 10/8/14, 4:46 AM

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.

Ludo - Neobis
on 10/8/14, 5:14 AM

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.

Anirudh Lou
on 10/8/14, 9:26 PM

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: 10/8/14, 4:04 AM
Seen: 518 times
Last updated: 3/16/15, 8:10 AM