From 90dfaa7addb9ffa72415fe46a6de16849004576c Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 17 Sep 2015 12:45:14 +0200 Subject: [PATCH] [FIX] delivery: add the delivery after all order lines in SO The delivery line in the SO was added among other lines, in second most of the time, due to the fact the sequence of the line was set after all other order lines sequences. opw-649629 --- addons/delivery/sale.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/delivery/sale.py b/addons/delivery/sale.py index 42fb1599070..d3e26e9258c 100644 --- a/addons/delivery/sale.py +++ b/addons/delivery/sale.py @@ -84,8 +84,7 @@ class sale_order(osv.Model): if order.company_id.currency_id.id != order.pricelist_id.currency_id.id: price_unit = currency_obj.compute(cr, uid, order.company_id.currency_id.id, order.pricelist_id.currency_id.id, price_unit, context=dict(context or {}, date=order.date_order)) - #create the sale order line - line_id = line_obj.create(cr, uid, { + values = { 'order_id': order.id, 'name': grid.carrier_id.name, 'product_uom_qty': 1, @@ -93,7 +92,10 @@ class sale_order(osv.Model): 'product_id': grid.carrier_id.product_id.id, 'price_unit': price_unit, 'tax_id': [(6, 0, taxes_ids)], - 'is_delivery': True - }, context=context) + 'is_delivery': True, + } + if order.order_line: + values['sequence'] = order.order_line[-1].sequence + 1 + line_id = line_obj.create(cr, uid, values, context=context) line_ids.append(line_id) return line_ids