콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
10041 화면

i have added a button wizard in purchase order form that contain reject button and special cancel button.

as soon as i click that button , the wizard form show up. Then after i fill every field in that wizard i have to click the reject button to execute the method. but my method doesn't return anything. did i put the wrong return ?

here's the code :

class reason_reject_approval(osv.osv_memory):
    _name = "reason.reject.approval"
    _columns = {
                'reason':fields.text('Reason')
                }
    
    def wtc_reject_approval(self, cr, uid, ids, context=None):
        val = self.browse(cr, uid, ids, context=context)
        user = self.pool.get("res.users").browse(cr, uid, uid)['groups_id']
        line = self.pool.get("purchase.order").browse(cr,uid,ids,context=context)
        
        for x in line.app_line :
            for y in user:
                    if y == x.group_id :
                        for z in line.app_line :
                                z.write(cr,uid,z.id,{
                                        'reason':val.reason,
                                        'value':line.amount_total,
                                        'sts':'3',
                                        'pelaksana':uid,
                                        'tanggal':datetime.today()
                                        })   
                                
        self.pool.get("purchase.order").action_cancel(cr, uid,ids)
        self.pool.get("purchase.order").write(cr, uid, ids, {'approval_state':'r'})
                                                      
        return True

--------------------------------------------------------------------------------------------------------------------------------------------------------------------

do you know how to solve it ? thanks.

아바타
취소

@ajeng what value you want to return and how will you use that returned value? what is your exact purpose? Also in the getting the browse record for 'purchase.order' you have directly use 'ids' which is wrong you should have used context.get('active_id')

작성자

in approval , there are 2 condition ,, approve and reject . if the reason is reject there must be a reason. I want that reason to show up in purchase order form .

작성자

previously i have added one2many field on purchase order called app_line it contain many fields , such as reason, value , sts, pelaksana, tanggal, etc. i have added two button approve and reject , reject is a wizard that i mean.

@Ajeng what have you used on the wizard to get the reason from the user? Is it just a text box? and if yes where exactly you want that value to be saved? If possible try posting some images of your screen so can better idea.

작성자

if you don't mind can i know your email ? i will sent directly by email

작성자

@emipro this is the link for what i mean https://berbagiopenerp.wordpress.com/2014/12/25/approval-purchase-order/

베스트 답변

Hello,

Please see the below function which is you need to correct which is called when you press "Reject" button on wizard.

import netsvc

def wtc_reject_approval(self, cr, uid, ids, context=None):
        val = self.browse(cr, uid, ids, context=context)
        user = self.pool.get("res.users").browse(cr, uid, uid)['groups_id']

        po_id = context.get('active_id',False) #When you call any wizard then in this function ids parameter contain the list of ids of the current wizard record. So, to get the purchase order ID you have to get it from context.
        line = self.pool.get("purchase.order").browse(cr,uid,po_id,context=context)
        
        for x in line.app_line :
            for y in user:
                    if y == x.group_id :
                        for z in line.app_line :
                                z.write(cr,uid,z.id,{
                                        'reason':val.reason,
                                        'value':line.amount_total,
                                        'sts':'3',
                                        'pelaksana':uid,
                                        'tanggal':datetime.today()
                                        })   
                                
        wf_service = netsvc.LocalService("workflow")

        wf_service.trg_validate(uid, 'purchase.order', po_id, 'purchase_cancel', cr)        

        self.pool.get("purchase.order").write(cr, uid, po_id, {'approval_state':'r'})
                                                      
        return True

I hope this function may setisfy your need.

아바타
취소
작성자

@Emipro , i am sorry , it still error , it said..... write() takes exactly 2 arguments (5 given)

작성자

@Emipro ... yeayyyy i did it !!! thank you so muchhh emipro .. i rewrite z.write{xxxxx} instead z.write{cr,uid,z.id} it works, thanks !!

Ohh, your z.write(...) called from browse object so you do not pass cr, uid, z.id. It may fix.

작성자

yes , it all thanks too you ..

This is the result <img goomoji="360" style="margin: 0px 0.2ex; vertical-align: middle;" src="cid:360@goomoji.gmail"> , Big Thanks for your Big HELP !! <img goomoji="330" style="margin: 0px 0.2ex; vertical-align: middle;" src="cid:330@goomoji.gmail">



2014-12-25 17:30 GMT+07:00 Emipro Technologies <erp@emiprotechnologies.com>:

Ohh, your z.write(...) called from browse object so you do not pass cr, uid, z.id. It may fix.

Emipro Technologies is best in Odoo & eCommerce Application development based outsourcing software firm. We deliver any kind of complex solutions in the domain of Odoo and eCommerce to customers accross the globe. Being in IT business since 2011, We have a strong team of skilled experienced IT experts.Our customers are companies of all sizes ranging from startups to large enterprises who realize that they need a professional internet solution to generate revenue streams, establish communication channels or streamline business operations.

Our Services in Odoo includes,
  • Installation
  • Customization
  • Configuration
  • Software Training
  • After Sale Support
  • Maintenance
  • Consulting
Contact info@emiprotechnologies.com for any kind of queries in Odoo. Visit www.emiprotechnologies.com for more details.




 

Sent by Odoo S.A. using Odoo about Forum Post False

작성자

@ Emipro i have different issue , if i use this method on purchase.requisition the workflow doesn't go to cancel state , did i have to use different code instead of this ? wf_service.trg_validate(uid, 'purchase.requisition', pr_id, 'tender_cancel', cr)

관련 게시물 답글 화면 활동
0
4월 16
5092
2
3월 15
9893
1
12월 22
3388
2
12월 20
16525
Expected singleton 해결 완료
9
3월 20
42187