Skip to Content
Menú
This question has been flagged
1 Respondre
5107 Vistes

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


Avatar
Descartar
Best Answer

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 , 




   

Avatar
Descartar
Autor

cant get u please give me example @ Prakash Sharma

Autor

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

Related Posts Respostes Vistes Activitat
3
de set. 23
3235
2
de set. 23
4372
2
de des. 21
12302
1
de nov. 19
5447
4
de maig 18
6448