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
77
78
79
80
81
-
I create customer invoice 6 - 120 USD - 1 EUR = 2 USD
-
!record {model: account.invoice, id: account_invoice_customer_6, view: invoice_form}:
journal_id: account.sales_journal
partner_id: base.res_partner_3
account_id: ds
vat_on_payment: True
currency_id: base.USD
date_invoice: !eval "'%s-08-14' %(datetime.now().year)"
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_6}
-
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 USD - 1 EUR = 4 USD
-
!record {model: account.voucher, id: account_voucher_6_a, view: account_voucher.view_vendor_receipt_form}:
partner_id: base.res_partner_3
amount: 100
journal_id: account.bank_journal_usd
date: !eval "'%s-08-15' %(datetime.now().year)"
-
I set the discount for 20
-
!python {model: account.voucher}: |
voucher = self.browse(cr, uid, ref('account_voucher_6_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_6_a}
-
I check the voucher
-
!python {model: account.voucher}: |
voucher = self.browse(cr, uid, ref('account_voucher_6_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.usd_bnk'):
bank_found = True
assert move_line.debit == 25, "Bank move line must be 25 debit, %s found" % move_line.debit
if move_line.account_id.id == ref('account.iva'):
vat_found = True
assert move_line.credit == 4.17, "VAT move line must be 4.17 credit, %s found" % move_line.credit
if move_line.account_id.id == ref('account.a_sale'):
sales_found = True
assert abs(move_line.credit - 20.83) < 0.01, "sales move line must be 20.83 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_6}:
- state == 'paid'