[FIX] fixed error in yaml test
[odoo/odoo.git] / addons / sale / test / manual_order_policy.yml
1 -
2   I confirm the Quotation with "Deliver & invoice on demand".
3 -
4   !workflow {model: sale.order, action: order_confirm, ref: order4}
5 -
6   I check that Invoice should not created.
7 -
8   !python {model: sale.order}: |
9     sale_order = self.browse(cr, uid, ref("order4"))
10     assert len(sale_order.invoice_ids) == False, "Invoice should not created."
11     assert sale_order.picking_ids, "Delivery order should be created."
12 -
13   I create advance invoice.
14 -
15   !python {model: sale.advance.payment.inv}: |
16     ctx = context.copy()
17     ctx.update({"active_model": 'sale.order', "active_ids": [ref("order4")], "active_id":ref("order4")})
18     order_line = self.pool.get('sale.order.line').browse(cr, uid, ref("line7"), context=context)
19     pay_id = self.create(cr, uid, {'product_id': order_line.product_id.id, 'amount': order_line.price_subtotal, 'qtty': order_line.product_uom_qty})
20     self.create_invoices(cr, uid, [pay_id], context=ctx)
21 -
22   I check Invoice which made advance
23 -
24   !python {model: sale.order}: |
25     order = self.browse(cr, uid, ref('order4'))
26     assert order.invoice_ids, "Invoice should be created after make advance invoice."
27 -
28   I create Invoice from sale order line.
29 -
30   !python {model: sale.order.line.make.invoice}: |
31     ctx = context.copy()
32     ctx.update({"active_model": 'sale.order.line', "active_ids": [ref("line8")], "active_id":ref("line8")})
33     self.make_invoices(cr, uid, [], context=ctx)
34 -
35   I check Invoice which made from sale order line.
36 -
37   !python {model: sale.order.line}: |
38     line = self.browse(cr, uid, ref('line8'))
39     assert line.invoiced, "Line is not invoiced."
40     assert line.invoice_lines, "Invoice line should be created."
41 -
42   I create manual Invoice for order.
43 -
44   !record {model: sale.make.invoice, id: sale_make_invoice_1}:
45     invoice_date: !eval time.strftime('%Y-%m-%d')
46 -
47   !python {model: sale.make.invoice}: |
48     ctx = context.copy()
49     ctx = ctx.update({"active_model": 'sale.order', "active_ids": [ref("order4")], "active_id":ref("order4")})
50     self.make_invoices(cr, uid, [ref("sale_make_invoice_1")], context)
51 -
52   I open the Invoice.
53 -
54   !python {model: sale.order}: |
55     import netsvc
56     wf_service = netsvc.LocalService("workflow")
57     so = self.browse(cr, uid, ref("order4"))
58     for invoice in so.invoice_ids:
59       wf_service.trg_validate(uid, 'account.invoice', invoice.id, 'invoice_open', cr)
60 -
61   I pay the invoice
62 -
63   !python {model: account.invoice}: |
64     sale_order = self.pool.get('sale.order')
65     order = sale_order.browse(cr, uid, ref("order4"))
66     journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', order.company_id.id)], limit=1)
67     for invoice in order.invoice_ids:
68         invoice.pay_and_reconcile(
69             invoice.amount_total, ref('account.cash'), ref('account.period_8'),
70             journal_ids[0], ref('account.cash'),
71             ref('account.period_8'), journal_ids[0],
72             name='test')
73 -
74   I check Invoice after do manual.
75 -
76   !python {model: sale.order}: |
77     sale_order = self.browse(cr, uid, ref("order4"))
78     assert sale_order.invoice_ids, "Invoice should be created."
79     assert sale_order.invoiced, "Order is not invoiced."
80     assert sale_order.state == 'manual', 'Order should be in Manual.'
81     
82 -
83   I set order policy "Deliver & invoice on demand" as default policy.
84 -
85   !record {model: sale.config.picking_policy, id: sale.config.picking_policy_0}:
86     order_policy: 'manual'
87 -
88   !python {model: sale.config.picking_policy}: |
89     self.execute(cr, uid, [ref("sale.config.picking_policy_0")])