Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
5110 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
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 Odpovědi Zobrazení Aktivita
3
zář 23
3241
2
zář 23
4403
2
pro 21
12314
1
lis 19
5450
4
kvě 18
6462