From 20312e28808f3c0abf2df75e850788dcfe54f577 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Fri, 13 Mar 2015 10:47:40 +0100 Subject: [PATCH] [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. --- addons/purchase/purchase.py | 6 +++--- addons/purchase/test/process/run_scheduler.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 6190c52b3b7..382e8596997 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -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, diff --git a/addons/purchase/test/process/run_scheduler.yml b/addons/purchase/test/process/run_scheduler.yml index 01aa497311d..83c5c6a099b 100644 --- a/addons/purchase/test/process/run_scheduler.yml +++ b/addons/purchase/test/process/run_scheduler.yml @@ -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'