Preserve order of sale line in invoice

(transplanted from 41ec52ac100e4174ad9c94d59d8c856c4f3b612c)
This commit is contained in:
Nicolas Évrard committed 2011-05-17 15:35:31 +02:00
1 parent a901c94f3b
commit 88fdbfad45
1 file changed
+6 -4
+6 -4
View File
@@ -705,7 +705,7 @@ class Sale(ModelWorkflow, ModelSQL, ModelView):
:param sale: the BrowseRecord of the sale
:param context: the context
:return: a dictionary with invoice line as key
:return: a dictionary with invoiced sale line id as key
and a list of invoice lines values as value
'''
line_obj = self.pool.get('sale.line')
@@ -767,12 +767,14 @@ class Sale(ModelWorkflow, ModelSQL, ModelView):
'payment_term': sale.payment_term.id,
}, context=ctx)
for line_id in invoice_lines:
for vals in invoice_lines[line_id]:
for line in sale.lines:
if line.id not in invoice_lines:
continue
for vals in invoice_lines[line.id]:
vals['invoice'] = invoice_id
invoice_line_id = invoice_line_obj.create(cursor, 0, vals,
context=ctx)
sale_line_obj.write(cursor, user, line_id, {
sale_line_obj.write(cursor, user, line.id, {
'invoice_lines': [('add', invoice_line_id)],
}, context=context)