diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 364ca36b1c2..af62b014c05 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -525,14 +525,18 @@ class sale_order(osv.osv): if grouped: res = self._make_invoice(cr, uid, val[0][0], reduce(lambda x, y: x + y, [l for o, l in val], []), context=context) invoice_ref = '' + origin_ref = '' for o, l in val: - invoice_ref += o.name + '|' + invoice_ref += (o.client_order_ref or o.name) + '|' + origin_ref += (o.origin or o.name) + '|' self.write(cr, uid, [o.id], {'state': 'progress'}) cr.execute('insert into sale_order_invoice_rel (order_id,invoice_id) values (%s,%s)', (o.id, res)) #remove last '|' in invoice_ref - if len(invoice_ref) >= 1: + if len(invoice_ref) >= 1: invoice_ref = invoice_ref[:-1] - invoice.write(cr, uid, [res], {'origin': invoice_ref, 'name': invoice_ref}) + if len(origin_ref) >= 1: + origin_ref = origin_ref[:-1] + invoice.write(cr, uid, [res], {'origin': origin_ref, 'name': invoice_ref}) else: for order, il in val: res = self._make_invoice(cr, uid, order, il, context=context)