[MERGE] forward port of branch 7.0 up to revid 10012 launchpad_translations_on_behalf...
[odoo/odoo.git] / addons / account_voucher / test / sales_payment.yml
1
2   I test sales payment with user who is accountant. 
3 -
4   !context
5     uid: 'res_users_account_voucher_user'
6 -
7   Create an invoice for the partner Seagate with amount 450.0
8 -
9   !record {model: account.invoice, id: account_invoice_0}:
10     account_id: account.a_recv
11     company_id: base.main_company
12     currency_id: base.EUR
13     invoice_line:
14       - account_id: account.a_sale
15         name: '[PCSC234] PC Assemble SC234'
16         price_unit: 450.0
17         quantity: 1.0
18         product_id: product.product_product_3
19         uos_id: product.product_uom_unit
20     journal_id: account.sales_journal
21     partner_id: base.res_partner_19
22
23 -
24   I check that the customer invoice is in draft state
25 -
26   !assert {model: account.invoice, id: account_invoice_0}:
27     - state == 'draft'
28
29 -
30   I make the invoice in Open state
31 -
32   !workflow {model: account.invoice, action: invoice_open, ref: account_invoice_0}
33
34 -
35   I check that a payment entry gets created in the account.move.line
36 -
37   !python {model: account.invoice}: |
38     acc_id=self.browse(cr, uid, ref("account_invoice_0"))
39     assert(acc_id.move_id)
40
41 -
42   I will create and post an account voucher of amount 450.0 for the partner Seagate.
43 -
44   !python {model: account.voucher}: |
45     vals = {}
46     journal_id = self.default_get(cr, uid, ['journal_id']).get('journal_id',None)
47     voucher = self.recompute_voucher_lines(cr, uid, [], ref("base.res_partner_19"), journal_id, 450.0, ref('base.EUR'), 'receipt', False)
48     assert (voucher['value'].get('writeoff_amount') == 0.0), "Writeoff amount calculated by recompute_voucher_lines() is not 0.0"
49     res = self.onchange_partner_id(cr, uid, [], ref("base.res_partner_19"), journal_id, 0.0, 1, ttype='receipt', date=False)
50     vals = {
51         'account_id': ref('account.cash'),
52         'amount': 450.0,
53         'company_id': ref('base.main_company'),
54         'journal_id': ref('account.bank_journal'),
55         'partner_id': ref('base.res_partner_19'),
56         'period_id': ref('account.period_8'),
57         'type': 'receipt',
58     }
59     if not res['value']['line_cr_ids']:
60       res['value']['line_cr_ids'] = [{'type': 'cr', 'account_id': ref('account.a_recv'),}]
61     #clients aren't sending value of readonly fields in the view, and there is a good reason for that, so here the
62     #create should only use values of fields that are not readonly. That's why i'm removing some of these values
63     del(res['value']['line_cr_ids'][0]['date_original'])
64     del(res['value']['line_cr_ids'][0]['date_due'])
65     res['value']['line_cr_ids'][0]['amount'] = 450.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.writeoff_amount == 0.0), "Writeoff amount is not 0.0"
70     assert (voucher_id.state=='draft'), "Voucher is not in draft state"
71     self.signal_proforma_voucher(cr, uid, [voucher_id.id])
72
73 -
74   Finally i will Confirm the state of the invoice is paid
75 -
76   !assert {model: account.invoice, id: account_invoice_0}:
77     - state == 'paid'