[FIX] purchase: on unlink purchase order line, cancel procurements associated to the move of the purchase order line
bzr revid: dle@openerp.com-20140120170729-57fm8tluz5p4zdk5
This commit is contained in:
parent
c09798bfbb
commit
4f3a4dce3b
|
@ -902,6 +902,15 @@ class purchase_order_line(osv.osv):
|
|||
default.update({'state':'draft', 'move_ids':[],'invoiced':0,'invoice_lines':[]})
|
||||
return super(purchase_order_line, self).copy_data(cr, uid, id, default, context)
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
procurement_ids_to_cancel = []
|
||||
for line in self.browse(cr, uid, ids, context=context):
|
||||
if line.move_dest_id:
|
||||
procurement_ids_to_cancel.extend(procurement.id for procurement in line.move_dest_id.procurements)
|
||||
if procurement_ids_to_cancel:
|
||||
self.pool['procurement.order'].action_cancel(cr, uid, procurement_ids_to_cancel)
|
||||
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,
|
||||
partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
|
||||
name=False, price_unit=False, context=None):
|
||||
|
|
|
@ -24,3 +24,13 @@
|
|||
!python {model: procurement.order}: |
|
||||
procurement = self.browse(cr, uid, ref('procurement_order_testcase0'))
|
||||
assert procurement.purchase_id, 'RFQ should be generated!'
|
||||
-
|
||||
I delete the line from the purchase order and check that the move and the procurement are cancelled
|
||||
-
|
||||
!python {model: procurement.order}: |
|
||||
procurement = self.browse(cr, uid, ref('procurement_order_testcase0'))
|
||||
move = procurement.purchase_id.order_line[0].move_dest_id
|
||||
procurement.purchase_id.order_line[0].unlink()
|
||||
assert move.state == 'cancel', 'Move should be cancelled'
|
||||
procurement.refresh()
|
||||
assert procurement.state == 'cancel', 'Procurement should be cancelled'
|
||||
|
|
Loading…
Reference in New Issue