Skip to Content
Menu
This question has been flagged
2905 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

Avatar
Discard

Can you please explain what you exactly need?

Author

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.

Related Posts Replies Views Activity
0
Jan 24
379
2
May 23
6770
0
Jan 23
819
1
Feb 22
21407
5
Dec 21
15004