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.

0

how to return a value from wizard form ?

By
Ajeng Shilvie
on 12/25/14, 1:40 AM 1,733 views

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

Emipro Technologies Pvt. Ltd.
on 12/25/14, 1:51 AM

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 .

Ajeng Shilvie
on 12/25/14, 2:23 AM

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 Shilvie
on 12/25/14, 2:25 AM

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

Emipro Technologies Pvt. Ltd.
on 12/25/14, 4:23 AM

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

Ajeng Shilvie
on 12/25/14, 4:32 AM

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

Ajeng Shilvie
on 12/25/14, 4:53 AM
1

Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
http://www.odoo.com
5975
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.

 

Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 

 

We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :

 

  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 12/25/14, 5:16 AM

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)

Ajeng Shilvie
on 12/25/14, 5:27 AM

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

Ajeng Shilvie
on 12/25/14, 5:30 AM

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

Emipro Technologies Pvt. Ltd.
on 12/25/14, 5:30 AM

yes , it all thanks too you ..

Ajeng Shilvie
on 12/25/14, 5:32 AM
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

Ajeng Shilvie
on 12/25/14, 5:36 AM

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

Ajeng Shilvie
on 12/25/14, 6:10 AM

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/25/14, 1:40 AM
Seen: 1733 times
Last updated: 3/16/15, 8:10 AM