Odoo Help

1

search method condition

By
Ajeng Shilvie
on 12/23/14, 2:40 AM 610 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 ,,

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

Emipro Technologies Pvt. Ltd.
on 12/23/14, 2:52 AM
1

Ivan

--Ivan--
Ivan
3235
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 12/23/14, 5:37 AM

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.

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 platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 12/23/14, 2:40 AM
Seen: 610 times
Last updated: 3/16/15, 8:10 AM