コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
5252 ビュー

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


アバター
破棄
最善の回答

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

著作者

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

関連投稿 返信 ビュー 活動
3
9月 23
3487
2
9月 23
4668
2
12月 21
12580
1
11月 19
5624
4
5月 18
6654