2 In order to test the cancel sale order.
4 I try to cancel sale order and It's order policy is Manual.
6 !python {model: sale.order}: |
8 self.action_cancel(cr, uid, [ref("order4")])
12 To cancel the sale order from Invoice Exception, I have to cancel the invoice of sale order.
14 !python {model: sale.order}: |
16 wf_service = netsvc.LocalService("workflow")
17 wf_service.trg_validate(uid, 'sale.order', ref('order3'), 'order_confirm', cr)
19 invoice_ids = [x.id for x in self.browse(cr, uid, ref("order3")).invoice_ids]
20 for invoice in invoice_ids:
21 wf_service.trg_validate(uid, 'account.invoice', invoice, 'invoice_cancel', cr)
23 #code introduced by revid: mtr@tinyerp.com-20110915060653-cbedeckll1ijre66
24 #form 'lp:~openerp-dev/openobject-addons/trunk-sale_coverage-mtr' branch
27 I check order status in "Invoice Exception" and related invoice is in cancel state.
29 !python {model: sale.order}: |
30 order = self.browse(cr, uid, ref("order3"))
31 assert order.invoice_ids[0].state == "cancel","order's related invoice should be cancelled"
32 assert order.state == "invoice_except", "Order should be in Invoice Exception state after cancel Invoice"
34 Then I click on the Ignore Exception button.
36 !workflow {model: sale.order, action: invoice_corrected, ref: order3}
38 And then again I set the invoice to draft state.
40 !python {model: account.invoice}: |
41 sale_order_obj = self.pool.get('sale.order')
42 so = sale_order_obj.browse(cr, uid, ref("order3"))
43 invoice_id = self.search(cr, uid, [('origin','=',so.name),('state','=','cancel')])
44 self.action_cancel_draft(cr, uid, invoice_id, ({'active_model': 'ir.ui.menu','active_ids': [ref("sale.menu_sale_order")], 'type': 'out_invoice', 'active_id': ref("sale.menu_sale_order")},))
46 Now I creating a partial picking.
48 !python {model: sale.order}: |
50 order = self.browse(cr, uid, ref("order4"))
51 assert order.picking_ids, "Picking is not created for this sale order"
52 partial_pick = self.pool.get('stock.partial.picking')
53 stock = self.pool.get('stock.picking')
54 pick_ids = [x.id for x in self.browse(cr, uid, ref("order4")).picking_ids]
55 data = stock.force_assign(cr, uid, pick_ids)
57 context={'active_model': 'stock.picking','active_ids': pick_ids}
58 partial_id = partial_pick.create(cr, uid, {},context)
59 partial = partial_pick.browse(cr,uid,partial_id)
60 line_id = partial.move_ids[0].id
61 partial_pick.write(cr, uid, partial_id, {'move_ids': [(1,line_id,{'update_cost': 0, 'product_id': ref('product.product_product_pc1'), 'product_uom': ref('product.product_uom_unit'), 'currency': False, 'prodlot_id': False, 'cost': False, 'location_dest_id': ref('stock.stock_location_customers'), 'location_id': ref('stock.stock_location_stock'), 'quantity': 5})]})
62 partial_pick.do_partial(cr, uid, [partial_id], context)
64 Now I cancel a partial picking.
66 !python {model: sale.order}: |
68 order = self.browse(cr, uid, ref("order4"))
69 assert len(order.picking_ids) >= 2,'After partial picking there must be two or more picking'
70 assert order.picking_ids[0].state == 'assigned',"Partial Picking should be in 'Ready to progress' state"
71 assert order.picking_ids[0].move_lines[0].product_qty == 10.0,"Partial Picking product quantity must be 10.0"
72 pick_ids = order.picking_ids
73 wf_service = netsvc.LocalService("workflow")
74 wf_service.trg_validate(uid, 'stock.picking', order.picking_ids[0].id, 'button_cancel', cr)
78 !function {model: procurement.order, name: run_scheduler}:
79 - model: procurement.order
82 Now I cancel a partial picking.
84 !python {model: sale.order}: |
86 order = self.browse(cr, uid, ref("order4"))
89 #code introduced by revid: mtr@tinyerp.com-20110921101038-xf1l3whyblmjbdx9
90 #form 'lp:~openerp-dev/openobject-addons/trunk-sale_coverage-mtr' branch
92 Then I click on the "Recreate Packing" button on sale order
94 !workflow {model: sale.order, action: ship_recreate, ref: order4}
96 I verfiy that sale order state is now 'In Progress'.
98 !assert {model: sale.order, id: order4}:
101 I verify that picking is generated for sale order.
103 !python {model: stock.picking}: |
104 order = self.browse(cr, uid, ref("order4"))
105 picking_id = self.search(cr, uid, [('sale_id','=',ref("order4"))])
106 assert picking_id,"Picking has not been generated"
108 Now I need to cancel the rekated picking of sale order.
110 !python {model: sale.order}: |
112 order = self.browse(cr, uid, ref("order4"))
113 picking_ids = [x.id for x in self.browse(cr, uid, ref("order4")).picking_ids]
114 wf_service = netsvc.LocalService("workflow")
115 for picking in picking_ids:
116 wf_service.trg_validate(uid, 'stock.picking', picking, 'button_cancel', cr)
118 Now I am able to cancel this sale order.
120 !python {model: sale.order}: |
121 self.action_cancel(cr, uid, [ref("order4")])
123 I check that sale order is cancelled.
125 !assert {model: sale.order, id: order4}:
128 Again set cancelled order to draft.
130 !python {model: sale.order}: |
131 self.action_cancel_draft(cr, uid, [ref("order4")])