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

Invoice Refund

By
Jihen BEN ALI
on 5/24/16, 3:04 AM 239 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???

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

Hi

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)

    vals.update(res.get('value',{}))

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

Hello, thanks for your answer but could you explain more

Jihen BEN ALI
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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

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