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.

0

for slip in self.browse(cu, uid, ids, context=None): NameError: global name 'cu' is not defined

By
praveen
on 4/3/14, 8:40 AM 2,965 views
def prasent_days(self, cr, uid, ids, field_names, args, context=None):
    res={}
    user_att = self.pool.get("hr.attendance")
    for slip in self.browse(cu, uid, ids, context=None):
        temp = 0
        att_ids = user_att.search(cu, uid, [('employee_id','=',slip.employee_id.id)])        
        for count in user_att.browse(cu, uid, att_ids, context=None):
            if count.name  >= slip.date_from and count.name <= slip.date_to: #This is not a good condition
                temp = temp + 1.0
        res[id]=temp 
    return res

_columns = {
       'es_present':fields.function(prasent_days, "No.of Present Days"),  
esteem_payslip()

In the present_days inside method change cu into cr

Prakash
on 4/3/14, 8:52 AM
0

Jagdish Panchal

--Jagdish Panchal--
2674
| 5 3 6
Gandhinagar, India
--Jagdish Panchal--

OpenERP Developer

Jagdish Panchal
On 4/3/14, 8:54 AM

Hi

def prasent_days(self, cr, uid, ids, field_names, args, context=None):
    res={}
    user_att = self.pool.get("hr.attendance")
    for slip in self.browse(cr, uid, ids, context=None):
        temp = 0
        att_ids = user_att.search(cr, uid, [('employee_id','=',slip.employee_id.id)])        
        for count in user_att.browse(cr, uid, att_ids, context=None):
            if count.name  >= slip.date_from and count.name <= slip.date_to: #This is not a good condition
                temp = temp + 1.0
        res[id]=temp 
    return res

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

0 follower(s)

Stats

Asked: 4/3/14, 8:40 AM
Seen: 2965 times
Last updated: 3/16/15, 8:10 AM