[IMP] Deleting PO lines should work the same way as Cancelling PO

Also the test is adapted.  When a product as treated as MTO, it should not
without notice change to an MTS.
This commit is contained in:
Josse Colpaert 2015-03-13 10:47:40 +01:00
parent 09abac7608
commit 20312e2880
2 changed files with 4 additions and 4 deletions

View File

@ -1026,9 +1026,9 @@ class purchase_order_line(osv.osv):
if line.state not in ['draft', 'cancel']:
raise osv.except_osv(_('Invalid Action!'), _('Cannot delete a purchase order line which is in state \'%s\'.') %(line.state,))
procurement_obj = self.pool.get('procurement.order')
procurement_ids_to_cancel = procurement_obj.search(cr, uid, [('purchase_line_id', 'in', ids)], context=context)
if procurement_ids_to_cancel:
self.pool['procurement.order'].cancel(cr, uid, procurement_ids_to_cancel)
procurement_ids_to_except = procurement_obj.search(cr, uid, [('purchase_line_id', 'in', ids)], context=context)
if procurement_ids_to_except:
self.pool['procurement.order'].write(cr, uid, procurement_ids_to_except, {'state': 'exception'}, context=context)
return super(purchase_order_line, self).unlink(cr, uid, ids, context=context)
def onchange_product_uom(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id,

View File

@ -39,4 +39,4 @@
procurement = self.browse(cr, uid, ref('procurement_order_testcase0'))
procurement.purchase_line_id.unlink()
procurement.refresh()
assert procurement.state == 'cancel', 'Procurement should be cancelled'
assert procurement.state == 'exception', 'Procurement should be in exception'