[FIX] purchase: delete unnecessary PO line
In v8.0, when a procurement is cancelled and the quantity remaining on the PO line is zero, the line is deleted. It was not the case anymore after the Purchase refactoring. opw-675493
This commit is contained in:
@@ -607,7 +607,7 @@ class PurchaseOrderLine(models.Model):
|
||||
raise UserError(_('Cannot delete a purchase order line which is in state \'%s\'.') %(line.state,))
|
||||
for proc in line.procurement_ids:
|
||||
proc.message_post(body=_('Purchase order line deleted.'))
|
||||
line.procurement_ids.write({'state': 'exception'})
|
||||
line.procurement_ids.filtered(lambda r: r.state != 'cancel').write({'state': 'exception'})
|
||||
return super(PurchaseOrderLine, self).unlink()
|
||||
|
||||
@api.model
|
||||
@@ -750,8 +750,10 @@ class ProcurementOrder(models.Model):
|
||||
if seller and seller.product_uom != procurement.purchase_line_id.product_uom:
|
||||
price_unit = self.env['product.uom']._compute_price(seller.product_uom.id, price_unit, to_uom_id=procurement.purchase_line_id.product_uom.id)
|
||||
|
||||
procurement.purchase_line_id.product_qty = product_qty
|
||||
procurement.purchase_line_id.price_unit = price_unit
|
||||
procurement.purchase_line_id.product_qty = product_qty
|
||||
procurement.purchase_line_id.price_unit = price_unit
|
||||
else:
|
||||
procurement.purchase_line_id.unlink()
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
# Cancel the Sales Order 1
|
||||
self.cancel(cr, uid, [so1.order_line[0].procurement_ids[0].id], context=context)
|
||||
assert so1.order_line[0].procurement_ids[0].state == u'cancel', 'Procurement 1 should be cancelled !'
|
||||
assert purchase_line.product_qty == 0.0, 'The product quantity of the first order line should be 5 and not %s' % (purchase_line.product_qty,)
|
||||
assert len(purchase_ids.order_line) == 0, 'The PO line should have been unlinked!'
|
||||
|
||||
# Check that all procurements related are cancelled
|
||||
for procu in procu_ids:
|
||||
|
||||
Reference in New Issue
Block a user