Launchpad automatic translations update.
[odoo/odoo.git] / addons / sale / test / cancel_order.yml
1 -
2   In order to test the cancel sale order.
3   I confirm order (with at least 2 lines)
4 -
5   !workflow {model: sale.order, action: order_confirm, ref: sale_order_8}
6
7 -
8   I check state of order in 'Sale Order'.
9 -
10   !assert {model: sale.order, id: sale_order_8, string: Sale order should be In Progress state}:
11     - state == 'manual'  
12 -
13   I check that Invoice should not be created.
14 -
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."
18 -
19   I create an invoice for the first line
20 -
21    !python {model: sale.order.line.make.invoice}: |
22
23     ctx = context.copy()
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
28 -
29   I create an invoice for a fixed price (25% of the second line, thus 5)
30 -
31    !python {model: sale.advance.payment.inv}: |
32     ctx = context.copy()
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
37
38 -
39   I create an invoice for the remaining and check the amount (should be the remaining amount of second line)
40 -
41    !python {model: sale.advance.payment.inv}: |
42     ctx = context.copy()
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"
50 -
51   I cancel all the invoices.
52 -
53   !python {model: sale.order}: |
54     import netsvc
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)
59 -
60   I check order status in "Invoice Exception" and related invoice is in cancel state.
61 -
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"
64
65   I click recreate invoice.
66 -
67   !workflow {model: sale.order, action: invoice_recreate, ref: sale_order_8}
68
69   I check that the invoice is correctly created with all lines.
70 -
71   !python {model: sale.order}: |
72     sale_order = self.browse(cr, uid, ref("sale_order_8"))
73     total_order_line = 0
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
79