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