[FIX] sale: corrected invoice creation from a sale order that already had some invoice generated from line(s)
bzr revid: qdp-launchpad@tinyerp.com-20101005161130-ctum7l1ksxt2k2a2
This commit is contained in:
parent
a0651cce14
commit
fb5d961ddd
|
@ -423,8 +423,14 @@ class sale_order(osv.osv):
|
|||
pay_term = order.payment_term.id
|
||||
else:
|
||||
pay_term = False
|
||||
invoiced_sale_line_ids = self.pool.get('sale.order.line').search(cr, uid, [('order_id', '=', order.id), ('invoiced', '=', True)], context=context)
|
||||
from_line_invoice_ids = []
|
||||
for invoiced_sale_line_id in self.pool.get('sale.order.line').browse(cr, uid, invoiced_sale_line_ids, context=context):
|
||||
for invoice_line_id in invoiced_sale_line_id.invoice_lines:
|
||||
if invoice_line_id.invoice_id.id not in from_line_invoice_ids:
|
||||
from_line_invoice_ids.append(invoice_line_id.invoice_id.id)
|
||||
for preinv in order.invoice_ids:
|
||||
if preinv.state not in ('cancel',):
|
||||
if preinv.state not in ('cancel',) and preinv.id not in from_line_invoice_ids:
|
||||
for preline in preinv.invoice_line:
|
||||
inv_line_id = self.pool.get('account.invoice.line').copy(cr, uid, preline.id, {'invoice_id': False, 'price_unit': -preline.price_unit})
|
||||
lines.append(inv_line_id)
|
||||
|
@ -471,7 +477,6 @@ class sale_order(osv.osv):
|
|||
lines = []
|
||||
for line in o.order_line:
|
||||
if line.invoiced:
|
||||
#raise osv.except_osv(_('Error !'), _('The Sale Order already has some lines invoiced. You should continue the billing process by line.'))
|
||||
continue
|
||||
elif (line.state in states):
|
||||
lines.append(line.id)
|
||||
|
|
Loading…
Reference in New Issue