Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
9915 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ

@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')

Tác giả

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 .

Tác giả

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.

Tác giả

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

Tác giả

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

Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Tác giả

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

Tác giả

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

Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 4 16
4962
2
thg 3 15
9704
1
thg 12 22
3231
2
thg 12 20
16402
Expected singleton Đã xử lý
9
thg 3 20
42030