2
I create a cash account type
4
!record {model: account.account.type, id: account_account_type_cash_0}:
11
I create a X11003 Cash Account.
13
!record {model: account.account, id: account_account_cash0}:
15
company_id: base.main_company
16
currency_mode: current
20
user_type : account_account_type_cash_0
21
activation_date: !eval time.strftime('%Y-01-01')
23
We create Timesheet journal for employee.
25
!record {model: account.analytic.journal, id: analytic_journal_1}:
27
name: Cash Analytic Journal
30
In order to check the Journal default value and register creation, we create a new cash journal.
32
!record {model: account.journal, id: account_journal_1}:
33
name: Cash Journal EUR
37
analytic_journal_id: analytic_journal_1
38
default_debit_account_id: account_account_cash0
39
default_credit_account_id: account_account_cash0
41
We check that the default parameters are correctly set
43
!assert {model: account.journal, id: account_journal_1}:
45
- centralisation == False
46
- entry_posted == False
47
- update_posted == True
48
- group_invoice_lines == False
50
We check that the cash register was created
52
!assert {model: account.bank.statement, search: "[('journal_id', '=', ref('account_journal.account_journal_1'))]"}:
53
- name == 'Cash Journal EUR'
54
- currency.id == ref("base.EUR")
56
In order to test engagement journal, I create an invoice with the global_distrib_1 (75% for gabon, 25% for Kenya)
58
!record {model: account.invoice, id: invoice_for_engagement_1}:
59
account_id: account.a_pay
60
address_contact_id: base.res_partner_address_3000
61
address_invoice_id: base.res_partner_address_3000
63
company_id: base.main_company
65
journal_id: account.expenses_journal
66
partner_id: base.res_partner_desertic_hispafuentes
69
analytic_distribution_id: global_distrib_1
70
date_invoice: !eval time.strftime('%Y-%m-%d')
72
Then I add an invoice line in order it takes analytic distribution from invoice
74
!python {model: account.invoice.line}: |
76
'account_id': ref('account_account_expense0'),
77
'name': 'Product PC1',
79
'product_id': ref('product.product_product_pc1'),
81
'uos_id': ref('product.product_uom_unit'),
82
'invoice_id': ref('account_journal.invoice_for_engagement_1'),
84
self.create(cr, uid, vals)
86
We validate the invoice
88
!python {model: account.invoice}: |
89
self.action_open_invoice(cr, uid, [ref('invoice_for_engagement_1')])
91
I check that analytic lines where written for Gabon and Kenya in funding_pool elements.
93
!python {model: account.analytic.line}: |
94
# We should 2 lines for each analytic account with an amount of -187.5 and one of -62.5
95
for el in [(187.50, ref('analytic_account_gabon')), (62.50, ref('analytic_account_kenya'))]:
96
search_ids = self.search(cr, uid, [('amount', '=', -1 * el[0])])
97
assert len(search_ids) == 1, "Some lines are missing."