[FIX] purchase: Shipping exception when cancelling a PO
When canceling and clicking on "reset to draft" button a PO with invoicing method = Based on generated draft invoice, the purchase workflow led to a shipping exception. To be in state done the PO must have: All its PO lines invoiced with _set_po_lines_invoiced All its incoming shipments done with test_moves_done opw:673561
This commit is contained in:
parent
f992c8ee19
commit
6057e645d6
|
@ -653,6 +653,14 @@ class purchase_order(osv.osv):
|
|||
return False
|
||||
self.write(cr, uid, ids, {'state':'draft','shipped':0})
|
||||
self.set_order_line_status(cr, uid, ids, 'draft', context=context)
|
||||
for po in self.browse(cr, SUPERUSER_ID, ids, context=context):
|
||||
for picking in po.picking_ids:
|
||||
picking.move_lines.write({'purchase_line_id': False})
|
||||
for invoice in po.invoice_ids:
|
||||
po.write({'invoice_ids': [(3, invoice.id, _)]})
|
||||
for po_line in po.order_line:
|
||||
for invoice_line in po_line.invoice_lines:
|
||||
po_line.write({'invoice_lines': [(3, invoice_line.id, _)]})
|
||||
for p_id in ids:
|
||||
# Deleting the existing instance of workflow for PO
|
||||
self.delete_workflow(cr, uid, [p_id]) # TODO is it necessary to interleave the calls?
|
||||
|
|
Loading…
Reference in New Issue