Odoo Help


Fill invoice_line based on invoice_id

on 1/7/16, 2:31 AM 485 views

Hello everyone,

I want to fill invoice_line based on invoice_id, I have created a change function but I'm getting an error could you help me please.

This is my 2 functions:

def onchange_partner_id(self, type, partner_id, date_invoice=False, payment_term=False, partner_bank_id=False, company_id=False):

res = super(kms_invoice, self).onchange_partner_id(type, partner_id, date_invoice=date_invoice, payment_term=payment_term, partner_bank_id=partner_bank_id, company_id=company_id)

if partner_id:

invoice_id = self.env['account.invoice'].search([('partner_id', '=', partner_id)])

p = self.env['res.partner'].browse(partner_id)

print 'invoice_id',invoice_id

res = {'value':{'user_id': p.user_id},'domain':{'invoice_id':[('partner_id','=',partner_id)]}}

return res



def onchange_invoice_id(self, invoice_id, partner_id, context=None):



if invoice_id:

invoice_line_ids = self.env['account.invoice.line'].search( [('invoice_id', '=', invoice_id)])

# p = self.env['account.invoice.line'].browse(invoice_id)

print 'invoice_line_ids',invoice_line_ids


for line in invoice_line_ids:



'name': line.name,











res =vals.update({'invoice_line':r})

return res

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

0 follower(s)


Asked: 1/7/16, 2:31 AM
Seen: 485 times
Last updated: 1/7/16, 3:30 AM