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

Fill invoice_line based on invoice_id

By
Jihen BEN ALI
on 1/7/16, 2:31 AM 391 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

    

@api.multi

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

res={}

vals=0

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

r=[]

for line in invoice_line_ids:

r.append({

'product_id':line.product_id,

'name': line.name,

'company_id':line.company_id,

'account_id':line.account_id,

'account_analytic_id':line.account_analytic_id,

'quantity':line.quantity,

'uos_id':line.uos_id,

'price_unit':line.price_unit,

'discount':line.discount,

'invoice_line_tax_id':line.invoice_line_tax_id,

'price_subtotal':line.price_subtotal

})

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

Question tools

0 follower(s)

Stats

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