Skip to Content
Menu
This question has been flagged
1 Reply
3960 Views

Anyone have you ever saw this error ? i couldn't execute another method that has the same code as create method , here's the code for the create method :

def create(self, cr, uid, vals, context=None):
        obj_matrix = self.pool.get("wtc.approval.matrixbiaya")
        vit = obj_matrix.search(cr,uid, [
                                         ("cabang_id", "=", vals["cabang_id"]),
                                         ("form", "=", "Purchase Requisition"),
                                         ("divisi_id", "=", vals["divisi_id"])
                                        ])
        if not vit:
            raise osv.except_osv(('Perhatian !'), ("Cabang & Divisi Tidak Memiliki Matrix Approval"))
        
        data = obj_matrix.browse(cr, uid, vit)
        approval = []
        for x in data :
            approval.append([0, False, {
                             'group_id':x.group_id.id,
                             'cabang_id':x.cabang_id.id,
                             'divisi_id':x.divisi_id,
                             'form':x.form.id,
                             'wewenang':x.limit,
                             'sts':'1',                             
            }])
               
        vals["app_line"] = approval
        return super(approvalpr, self).create(cr, uid, vals, context=context)

then , it is another method :

def wtc_approval_request(self, cr, uid, ids,vals, context=None):
        obj_matrix = self.pool.get("wtc.approval.matrixbiaya")
        line = self.browse(cr, uid, ids, context=context)
        vit = obj_matrix.search(cr,uid, [
                                         ("cabang_id", "=", vals["cabang_id"]),
                                         ("form", "=", "purchase.order"),
                                         ("divisi_id", "=", vals["divisi_id"])
                                        ])
        
        data = obj_matrix.browse(cr, uid, vit)  
        approval = []
        for x in data :
            approval.append([0, False, {
                             'group_id':x.group_id.id,
                             'cabang_id':x.cabang_id.id,
                             'divisi_id':x.divisi_id,
                             'form':x.form.id,
                             'wewenang':x.limit,
                             'sts':'1',                             
            }])

        vals["app_line"] = approval
        return True

the code between two method is the same code , but how i got an error in vals[XXXXXXXX] ??

Thanks in advance ,,

Avatar
Discard

@ajeng please clarify your problem. Not getting exactly what is the issue

Best Answer

Depending on where wtc_approval_request is called from, my guess is it would not get vals variable passed.  That's why you get the error.  You need to post a fuller picture of how wtc_approval_request is defined (in which model) and used (using button? Called by another method?) if you need help in achieving your goal.  Also, it would help if you can describe what your goal is.

Avatar
Discard