Odoo Help


Invoice Refund

on 5/24/16, 3:04 AM 305 views

Hello everyone,

In the invoice I had added a field the invoice number and depending on this field the refund invoice line will be filled the pb is when I save those line are deleted.

This is my code:

'invoice_id' : fields.many2one('account.invoice', string='Invoice number'),

def onchange_invoice_id(self, cr, uid, ids, invoice_id, context=None):

obj_inv_line = self.pool.get('account.invoice.line')

acc_line_ids = []

if invoice_id:

acc_line_ids = obj_inv_line.search(cr, uid, [('invoice_id', '=', invoice_id)])

return {'value': {'invoice_line': acc_line_ids}}

Any help please???

ayman mohammed adam
On 5/25/16, 9:48 AM


you must overwrite create and write function, then you must  call this onchange function  and update vals dictionary values before the return like this:

def create(self, cr, uid, vals, context=None):

    res= {}

    res= self.onchange_invoice_id(cr, uid, [],vals.get('invoice_id',False), context=context)


    return super(your_class_name, self).create(cr, uid, vals, context=context)

Hello, thanks for your answer but could you explain more

on 5/27/16, 6:32 AM

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 platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 5/24/16, 3:04 AM
Seen: 305 times
Last updated: 5/27/16, 3:05 AM