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

"global name 'context' is not defined" ?

By
Abdullah Sofan
on 12/16/14, 11:27 AM 1,305 views

When I run this code I get the error : "global name 'context' is not defined"

Can someone tell me what I am doing wrong?

    def get_attendance(self, cr, uid, ids, bt_no, st_name, att_sheet_no, context=None):
        attend_obj = self.pool.get('intrac.attend')
        for records in attend_obj.search(cr, uid, [('batch_number', '=', bt_no),('student_name', '=', st_name),('attend_sheet','=', att_sheet_no)], context=context):
            get_att_record = attend_obj.browse(cr, uid, records)
            get_att = get_att_record.attend_present.id
            _res = get_att
            return _res

It is best if you check the traceback log first. The error may not be caused by this piece of code.

Ivan
on 12/16/14, 11:33 AM

@Ivan I checked the traceback log and it is pointing to the third line of the code above. I am not an expert and I am learning on my own. Can you help?

Abdullah Sofan
on 12/16/14, 11:50 AM
1
Abdullah Sofan
On 12/16/14, 1:04 PM

I figured it out. I modified the code in line 3 like this:

for records in attend_obj.search(cr, uid, [('batch_number', '=', bt_no),('student_name', '=', st_name),('attend_sheet','=', att_sheet_no)], context=None):

You should use context=context instead, not context=None.

Ivan
on 12/16/14, 6:24 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

2 follower(s)

Stats

Asked: 12/16/14, 11:27 AM
Seen: 1305 times
Last updated: 3/16/15, 8:10 AM