2 In order to test the cancel sale order.
3 I confirm order (with at least 2 lines)
5 !workflow {model: sale.order, action: order_confirm, ref: sale_order_8}
8 I check state of order in 'Sale Order'.
10 !assert {model: sale.order, id: sale_order_8, string: Sale order should be In Progress state}:
13 I check that Invoice should not be created.
15 !python {model: sale.order}: |
16 sale_order = self.browse(cr, uid, ref("sale_order_8"))
17 assert len(sale_order.invoice_ids) == False, "Invoice should not be created."
19 I create an invoice for the first line
21 !python {model: sale.order.line.make.invoice}: |
24 ctx.update({"active_model": 'sale.order.line', "active_ids": [ref("sale_order_line_20")], "active_id":ref("sale_order_line_20")})
25 pay_id = self.create(cr, uid, {})
26 self.make_invoices(cr, uid, [pay_id], context=ctx)
27 invoice_ids = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_8")).invoice_ids
29 I create an invoice for a fixed price (25% of the second line, thus 5)
31 !python {model: sale.advance.payment.inv}: |
33 ctx.update({"active_model": 'sale.order', "active_ids": [ref("sale_order_8")], "active_id":ref("sale_order_8")})
34 pay_id = self.create(cr, uid, {'advance_payment_method': 'fixed', 'amount': 5})
35 self.create_invoices(cr, uid, [pay_id], context=ctx)
36 invoice_ids = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_8")).invoice_ids
39 I create an invoice for the remaining and check the amount (should be the remaining amount of second line)
41 !python {model: sale.advance.payment.inv}: |
43 ctx.update({"active_model": 'sale.order', "active_ids": [ref("sale_order_8")], "active_id":ref("sale_order_8")})
44 pay_id = self.create(cr, uid, {'advance_payment_method': 'all'})
45 self.create_invoices(cr, uid, [pay_id], context=ctx)
46 invoice_ids = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_8")).invoice_ids
47 assert len(invoice_ids) == 3, "All invoices are not created"
48 for invoice in invoice_ids:
49 assert invoice.amount_total in (7290,5,20), "Invoice total is not correct"
51 I cancel all the invoices.
53 !python {model: sale.order}: |
55 invoice_ids = self.browse(cr, uid, ref("sale_order_8")).invoice_ids
56 wf_service = netsvc.LocalService("workflow")
57 for invoice in invoice_ids:
58 wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_cancel', cr)
60 I check order status in "Invoice Exception" and related invoice is in cancel state.
62 !assert {model: sale.order, id: sale_order_8, string: Sale order should be in Invoice Exception state}:
63 - state == "invoice_except", "Order should be in Invoice Exception state after cancel Invoice"
65 I click recreate invoice.
67 !workflow {model: sale.order, action: invoice_recreate, ref: sale_order_8}
69 I check that the invoice is correctly created with all lines.
71 !python {model: sale.order}: |
72 sale_order = self.browse(cr, uid, ref("sale_order_8"))
74 assert len(sale_order.invoice_ids), "Invoice should be created."
75 for invoice in sale_order.invoice_ids:
76 if invoice.state != 'cancel':
77 total_order_line += len(invoice.invoice_line)
78 assert total_order_line == 2, "wrong number of invoice lines, got %s" % total_order_line