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

Add a line on invoice which it's not on delivery order lines

By
Roberto Barreiro
on 10/21/15, 12:47 PM 452 views

I'm trying to add a line on invoices before delivery orders lines, but it seems my code it's not executed, i tryed this to test:

from openerp.osv import fields, osv

class sale_order_line(osv.osv):

_inherit = "sale.order.line"

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

res = super(sale_order_line,self).invoice_line_create(cr, uid, ids, context=None)
vals = {
'name': test,
'account_id': 1094,
'price_unit': 0,
'quantity':0,
}
inv_id = self.pool.get('account.invoice.line').create(cr, uid, vals, context=context)
self.write(cr, uid, 0, {'invoice_lines': [(4, inv_id)]}, context=context)
sales.add(0)
create_ids.append(inv_id)
return res

This code seems to do nothing. It could be an inherit problem or super is overwrtitting the result?.


EDITED ON 23/10/15

I had also tested this code, and messagebox it's not shown:

from openerp.osv import fields, osv

class sale_order_line(osv.osv):
_name = 'sale.order.line'
_inherit = 'sale.order.line'

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

res = super(sale_order_line, self).invoice_line_create(cr, uid, ids, context=context)
raise osv.except_osv(_('Test'), _('This is a test'))
return res

Can you please explain what you exactly need?

Akhil P Sivan
on 10/22/15, 10:48 PM

I want to add a line automatically on making an invoice from delivery orders. This line must be before the delivery order lines. For example, I added a field on delivery orders, and this field has a reference gave by the customer. If a customer send me a purchase order, and their purcharse order has a reference "x", I want that my invoice has that number "x" on the first invoice line. If my invoice contais more than 1 delivery order, after the lines of first delivery order, and before the lines of the second order, there must be the purchase order reference of the second delivery order on another line. Thank you soo much.

Roberto Barreiro
on 10/23/15, 4:34 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

1 follower(s)

Stats

Asked: 10/21/15, 12:47 PM
Seen: 452 times
Last updated: 10/23/15, 7:33 AM