Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
8350 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
4
ก.พ. 25
2704
1
ส.ค. 24
2234
2
พ.ย. 24
3371
3
ต.ค. 23
14905
2
ก.พ. 23
2505