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

Original function in "account.voucher" was:

    def button_proforma_voucher(self, cr, uid, ids, context=None):
        self.signal_workflow(cr, uid, ids, 'proforma_voucher')
        return {'type': 'ir.actions.act_window_close'}

 

I have overriden the base class function:

class MyAccountVoucher(models.Model):
    _inherit = "account.voucher"

# Override "Pay" button press method

    @api.one
    def button_proforma_voucher(self):
------ some code that works fine -----
 res = super(MyAccountVoucher,self).button_proforma_voucher
return res

Nothing happens. I assume that the problem may be in the middle between new and old api, but what is wrong in the code?

アバター
破棄

error log?

著作者

There is no error. It just does nothing. Like there is no function at all.

Try @api.multi and button_proforma_voucher() - with brackets.

著作者

Thank you! That worked

最善の回答

Hello Sam,

You did the mistake while defining function @api.one can not be use in case of multiple occurence.

And one another problem : in case of calling function you need to use ().

Use the following code:

@api.multi
    def button_proforma_voucher(self):
         ------ some code that works fine -----
         res = super(MyAccountVoucher,self).button_proforma_voucher()
         return res

Hope this will help you.

Thanks

アバター
破棄
関連投稿 返信 ビュー 活動
4
2月 25
2703
1
8月 24
2234
2
11月 24
3371
3
10月 23
14903
2
2月 23
2504