**Impacted versions:**
8.0

**Steps to reproduce:**

* The product is created with its respective configuration (it must be stokable, have a supplier and procurement by buy),  in the accouting tab the "inventory valuation" section should be "Real time".
* Proceed to create its reordering rule, it is assigned a value min = 100 and max = 160.                                                      
* Run Scheduler, Which generates a purchase order to supply the product created.                                                              
* The Reordering Rule is modified so that min = 120 and max = 170.                                                                            
* Run Scheduler, Which doubles the procurement for the product in question.                                                                   
* We locate the generated purchase order and change quantity = 170 to quantity = 160 in the product line, then it is confirmed and change Invoicing control to "Based on Incoming shipments". Update the Total.                                                                                             
* Confirm Order. Approve Order. "Go to Shipments". If we review the related picking we will see that for product line duplicate the input creating a second with quantity = 0 value.                                                                                                                        
* Transfer. Apply. Create Invoice. At this point we appreciate the invoice with a duplicate product line and with quantity value equal to zero.
* Validate. (traceback error)

**Current behaivor:**                                                                                                                                         
                                                                                                                                                              
Currently the process described above generates a duplicate product line and with quantity equal to zero for the picking and that is transferred to the invoice when we do the latter from the picking. As shown in the following video in an example from runbot.odoo.com  [ Here.](https://youtu.be/CziZuFZvGHo)                                                
                                                                                                                                                              
catch traceback error:
![traceback](https://cloud.githubusercontent.com/assets/11073475/25353055/090eb32c-28fc-11e7-975c-d35afe179bf8.png)


**Expected behaivor:**                                                                                                                                        
                                                                                                                                                              
Do not generate duplicate product line with quantity zero and thus avoid being transferred to the invoice generating a traceback error at the time of validating the invoice as shown:

Video/Screenshot link (optional):

https://youtu.be/CziZuFZvGHo


addons/purchase/purchase.py
new_id = super(purchase_order, self).copy(cr, uid, id, default=default, context=context)
        for po in self.browse(cr, uid, [new_id], context=context):
            for line in po.order_line:
                vals = self.pool.get('purchase.order.line').onchange_product_id(
                    cr, uid, line.id, po.pricelist_id.id, line.product_id.id, line.product_qty,
                    line.product_uom.id, po.partner_id.id, date_order=po.date_order, context=context
                )
                if vals.get('value', {}).get('date_planned'):
                    line.write({'date_planned': vals['value']['date_planned']})
        return new_id
    def set_order_line_status(self, cr, uid, ids, status, context=None):
        line = self.pool.get('purchase.order.line')
        order_line_ids = []
        proc_obj = self.pool.get('procurement.order')
        for order in self.browse(cr, uid, ids, context=context):
            if status in ('draft', 'cancel'):
                order_line_ids += [po_line.id for po_line in order.order_line]
            else: 
                order_line_ids += [po_line.id for po_line in order.order_line if po_line.state != 'cancel']
        if order_line_ids:
            line.write(cr, uid, order_line_ids, {'state': status}, context=context)
        if order_line_ids and status == 'cancel':
            procs = proc_obj.search(cr, uid, [('purchase_line_id', 'in', order_line_ids)], context=context)
            if procs:
                proc_obj.write(cr, uid, procs, {'state': 'exception'}, context=context)
        return True
    def button_dummy(self, cr, uid, ids, context=None):