Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
5254 Vistas

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
Mejor respuesta

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

Publicaciones relacionadas Respuestas Vistas Actividad
3
sept 23
3487
2
sept 23
4668
2
dic 21
12581
1
nov 19
5624
4
may 18
6654