1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
-
I create customer invoice 4 - 120 EUR
-
!record {model: account.invoice, id: account_invoice_customer_4, view: invoice_form}:
journal_id: account.sales_journal
partner_id: base.res_partner_3
account_id: ds
vat_on_payment: True
invoice_line:
- quantity: 1
account_id: account.a_sale
name: 'Service'
price_unit: 100.0
invoice_line_tax_id:
- tax20
-
I create invoice by clicking on Create button
-
!workflow {model: account.invoice, action: invoice_open, ref: account_invoice_customer_4}
-
I set the context that will be used for the encoding of all the vouchers of this file
-
!context
'type': 'receipt'
-
I create the Payment for 100
-
!record {model: account.voucher, id: account_voucher_4_a, view: account_voucher.view_vendor_receipt_form}:
partner_id: base.res_partner_3
amount: 100
-
I set the discount for 20
-
!python {model: account.voucher}: |
voucher = self.browse(cr, uid, ref('account_voucher_4_a'), context=context)
assert len(voucher.line_cr_ids) == 1, "There must be 1 voucher line, %s found" % len(voucher.line_cr_ids)
voucher.line_cr_ids[0].write({
'reconcile': True,
'amount': 120,
})
voucher.write({
'payment_option': 'with_writeoff',
'writeoff_acc_id': ref('account.a_expense'),
'exclude_write_off': False,
})
-
I confirm the voucher
-
!workflow {model: account.voucher, action: proforma_voucher, ref: account_voucher_4_a}
-
I check the voucher
-
!python {model: account.voucher}: |
voucher = self.browse(cr, uid, ref('account_voucher_4_a'), context=context)
assert len(voucher.move_id.line_id) == 3, "There must be 3 real move lines, %s found" % len(voucher.move_id.line_id)
bank_found = False
vat_found = False
sales_found = False
for move_line in voucher.move_id.line_id:
if move_line.account_id.id == ref('account.bnk'):
bank_found = True
assert move_line.debit == 100, "Bank move line must be 100 debit, %s found" % move_line.debit
if move_line.account_id.id == ref('account.iva'):
vat_found = True
assert move_line.credit == 16.67, "VAT move line must be 16.67 credit, %s found" % move_line.credit
if move_line.account_id.id == ref('account.a_sale'):
sales_found = True
assert move_line.credit == 83.33, "sales move line must be 83.33 credit, %s found" % move_line.credit
assert bank_found, "No bank move line found"
assert sales_found, "No sales move line found"
assert vat_found, "No VAT move line found"
-
I check that the invoice state is paid
-
!assert {model: account.invoice, id: account_invoice_customer_4}:
- state == 'paid'