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 validate a record creating through wizard?

By
vadivel
on 4/20/16, 6:20 AM 364 views

Hi friends,

I have customized new form for some calculation. i have defined a wizard button for entering a purchase receipt,i have pasted code below:

def action_purchase_receipt(self, cr, uid, ids, context=None):

if not ids: return []

dummy, view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_voucher', 'view_purchase_receipt_form')

# inv = self.browse(cr, uid, ids[0], context=context)

return {

'name':("Purchase Receipt"),

'view_mode': 'form',

'view_id': view_id,

'view_type': 'form',

'res_model': 'account.voucher',

'type': 'ir.actions.act_window',

'nodestroy': True,

'target': 'new',

'domain': '[]',

}

if i click on validate button, it exits without saving record in purchase receipt.

How to resolve this issue.Help me in this situation.Thanks in advance


0

Prakash Sharma

--Prakash Sharma--
815
| 2 1 4
Delhi, India
--Prakash Sharma--

I like to surround myself with brave, creative people.

My motivation for learning different technologies and algos drive me. I love challenges of a steep learning curve which I believe makes me a better learner. I have a strong desire to learn different technologies, which would enable me to become a full stack developer.

Prakash Sharma
On 4/20/16, 6:37 AM

create  it on save of  views that you have returned 

Edited:

hi vadivel ,you are returning view_purchase_receipt_form


Validate
button actually call the proforma_voucher method  define in  account.voucher, so please go through these steps:

#1 Override proforma_voucher ,

#2 At the time of returning the view, pass  the context also (pass a identifier to identify that this view is called by you )

#3 On the basis of context in side proforma_voucher create the purchase receipt.


@api.multi

def action_purchase_receipt(self):

view_id = self.env.ref('account_voucher.view_purchase_receipt_form')

# raise Warning(vi)

return {

'name':("Purchase Receipt"),

'view_mode': 'form',

'view_id': view_id.id,

'view_type': 'form',

'res_model': 'account.voucher',

'type': 'ir.actions.act_window',

'nodestroy': True,

'target': 'new',

'domain': '[]',

'context': {'purchase_receipt':True}

}


def proforma_voucher(self, cr, uid, ids, context=None):

if context.get('purchase_receipt'):

#do my task here

return super(account_voucher,self).proforma_voucher(cr, uid, ids, context)

Hope this help  you , 




   

cant get u please give me example @ Prakash Sharma

vadivel
on 4/20/16, 6:40 AM

please can u give me as a code,so it will helpful for me

vadivel
on 4/20/16, 6:49 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

1 follower(s)

Stats

Asked: 4/20/16, 6:20 AM
Seen: 364 times
Last updated: 4/20/16, 6:37 AM