Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3456 Zobrazení

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
Zrušit

Can you please explain what you exactly need?

Autor

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 Odpovědi Zobrazení Aktivita
3
čvc 25
8654
1
kvě 25
948
0
led 24
1680
0
led 23
1412
1
úno 22
23781