Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Call original function from parent class fails

By
Sam
on 1/28/15, 2:04 PM 1,652 views

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?

zbik
on 1/28/15, 2:56 PM

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

Sam
on 1/28/15, 2:58 PM

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

zbik
on 1/28/15, 4:15 PM

Thank you! That worked

Sam
on 1/29/15, 3:03 AM
1
Nishant Jogi
On 1/29/15, 12:35 AM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 1/28/15, 2:04 PM
Seen: 1652 times
Last updated: 3/16/15, 8:10 AM