[IMP] account_followup: use the new signal_xxx methods instead of trg_validate.
[odoo/odoo.git] / addons / account_voucher / test / sales_receipt.yml
1
2   Creating a Voucher Receipt for partner Seagate with amount 30000.0
3
4   !record {model: account.voucher, id: account_voucher_seagate_0, view: view_sale_receipt_form}:
5     account_id: account.a_recv
6     amount: 30000.0
7     company_id: base.main_company
8     journal_id: account.sales_journal
9     line_cr_ids:
10       - account_id: account.a_sale
11         amount: 30000.0
12         type: cr
13     partner_id: base.res_partner_19
14     period_id: account.period_9
15     type: sale
16     
17 -
18   I check that the voucher state is Draft
19 -
20   !assert {model: account.voucher, id: account_voucher_seagate_0}:
21     - state == 'draft'
22
23 -
24   I click on post button to post the voucher
25 -
26   !workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_seagate_0}
27
28 -
29   Check that the voucher state is Posted
30 -
31   !assert {model: account.voucher, id: account_voucher_seagate_0}:
32     - state == 'posted'
33     
34 -
35   I check that move lines are validated but not reconciled
36 -
37   !python {model: account.voucher}: |
38     reconciled = False
39     for l in self.browse(cr, uid, [ref("account_voucher_seagate_0")])[0].move_ids: 
40        if l.reconcile_id:
41          reconciled = True
42          break
43     assert (not reconciled), "Found reconciled move lines, should not be"
44 -
45   I create and post a voucher payment of amount 30000.0 for the partner Seagate
46 -
47   !python {model: account.voucher}: |
48     import netsvc
49     vals = {}
50     journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None)
51     res = self.onchange_partner_id(cr, uid, [], ref("base.res_partner_19"), journal_id, 0.0, 1, ttype='receipt', date=False)
52     vals = {
53         'account_id': ref('account.cash'),
54         'amount': 30000.0,
55         'company_id': ref('base.main_company'),
56         'journal_id': ref('account.bank_journal'),
57         'partner_id': ref('base.res_partner_19'),
58         'period_id': ref('account.period_8'),
59         'type': 'receipt',
60     }
61     if not res['value']['line_cr_ids']:
62       res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
63     res['value']['line_cr_ids'][0]['amount'] = 30000.0
64     vals['line_cr_ids'] = [(0,0,i) for i in res['value']['line_cr_ids']]
65     id = self.create(cr, uid, vals)
66     voucher_id = self.browse(cr, uid, id)
67     assert (voucher_id.state=='draft'), "Voucher is not in draft state"
68     wf_service = netsvc.LocalService("workflow")
69     wf_service.trg_validate(uid, 'account.voucher', voucher_id.id, 'proforma_voucher', cr)
70 -
71   I check that move lines are reconciled meaning voucher is paid
72 -
73   !python {model: account.voucher}: |
74     reconciled = False
75     for l in self.browse(cr, uid, [ref("account_voucher_seagate_0")])[0].move_ids: 
76        if l.reconcile_id:
77          reconciled = True
78          break
79     assert reconciled, "Found unreconciled move lines/unpaid voucher"