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

'Field name not found in browse_record(hr.attendance, 13)

By
praveen
on 4/2/14, 7:30 AM 1,420 views

_inherit = 'hr.payslip'

def prasent_days(self, cu, uid, ids, field_names, args, context=None):
    res={}
    temp = 0
    user_att = self.pool.get("hr.attendance")        
    for count in user_att.browse(cu, uid, ids, context=None):
        if count.name  >= date_from and count.name <= date_to:
            temp = temp + 1.0
    res[id]=temp 
    return res

_columns = {
       'es_present':fields.function(prasent_days, "No.of Present Days"),           
}
0
praveen
On 4/2/14, 7:34 AM

Hi I am trying to count no of days the employee signed in so to count no of presents in the office in a month

please help me

I am thinking if i iterate through the hr.attendance module to count no of days

class esteem_payslip(osv.osv):
_inherit = 'hr.payslip'

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()

this is not working

att_ids = user_att.search(cr, uid, [('employee_id','=',slip.employee_id.id)]) NameError: global name 'cr' is not defined

The comment is edited, change cu to cr, it's done

Yug Faa
on 4/2/14, 9:39 AM

NameError: global name 'cr' is not defined

praveen
on 4/2/14, 9:50 AM

This code is not working please help me

praveen
on 4/3/14, 8:37 AM
0
Yug Faa
On 4/2/14, 7:56 AM
def prasent_days(self, cu, 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(cr, 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"),           
}

att_ids = user_att.search(cr, uid, [('employee_id','=',slip.employee_id.id)]) NameError: global name 'cr' is not defined

praveen
on 4/2/14, 9:14 AM

Please help with the above error

praveen
on 4/2/14, 9:15 AM

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