2
In order to test the budget import,
4
I create, in order, a account type, ...
6
!record {model: account.account.type, id: account_account_type_expense0}:
14
!record {model: account.analytic.account, id: test_destination}:
15
name: "Test Destination"
19
...an "chart of accounts" account, ...
21
!record {model: account.account, id: test_chart_of_accounts}:
22
name: "MSF Chart of Accounts"
24
user_type: account_account_type_expense0
29
!record {model: account.account, id: test_expense}:
32
user_type: account_account_type_expense0
34
parent_id: test_chart_of_accounts
36
...a destination link, ...
38
!record {model: account.destination.link, id: test_destination_link}:
39
account_id: test_expense
40
destination_id: test_destination
44
!record {model: account.analytic.account, id: analytic_account_OC1}:
51
!record {model: account.analytic.account, id: analytic_account_OC2}:
58
!record {model: account.analytic.account, id: analytic_account_FP1}:
63
- analytic_account_OC2
64
tuple_destination_account_ids:
65
- test_destination_link
69
!record {model: account.analytic.account, id: analytic_account_FP2}:
74
- analytic_account_OC1
75
- analytic_account_OC2
76
tuple_destination_account_ids:
77
- test_destination_link
79
I set the company currency's rate to 1 for the move
81
!record {model: res.currency.rate, id: currency_rate_test_3}:
82
name: !eval "'%s-01-01' %(datetime.now().year+1)"
86
I set another currency's rate to 100 for the move
88
!record {model: res.currency.rate, id: currency_rate_test_4}:
89
name: !eval "'%s-01-01' %(datetime.now().year+1)"
93
...an analytical journal, ...
95
!record {model: account.analytic.journal, id: analytic_journal_1}:
97
name: Cash Analytic Journal
100
I create a cash account type
102
!record {model: account.account.type, id: account_account_type_cash_0}:
103
close_method: balance
110
I create a X11003 Cash Account.
112
!record {model: account.account, id: account_account_cash0}:
114
company_id: base.main_company
115
currency_mode: current
119
user_type : account_account_type_cash_0
120
activation_date: !eval time.strftime('%Y-01-01')
124
!record {model: account.journal, id: account_journal_1}:
129
analytic_journal_id: analytic_journal_1
130
default_debit_account_id: account_account_cash0
131
default_credit_account_id: account_account_cash0
133
...a fiscal year, ...
135
!record {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0}:
136
code: !eval "'FY%s'% (datetime.now().year+1)"
137
company_id: base.main_company
138
date_start: !eval "'%s-01-01' %(datetime.now().year+1)"
139
date_stop: !eval "'%s-12-31' %(datetime.now().year+1)"
140
name: !eval "'Fiscal Year %s' %(datetime.now().year+1)"
144
!record {model: account.period, id: account_period_mar0}:
145
company_id: base.main_company
146
date_start: !eval "'%s-03-01' %(datetime.now().year+1)"
147
date_stop: !eval "'%s-03-31' %(datetime.now().year+1)"
148
fiscalyear_id: account_fiscalyear_fiscalyear0
149
name: !eval "'Mar %s' %(datetime.now().year+1)"
153
... and a distribution.
155
!record {model: analytic.distribution, id: distribution_test}:
157
- analytic_id: analytic_distribution.analytic_account_msf_private_funds
158
cost_center_id: analytic_account_OC1
159
destination_id: test_destination
161
currency_id: base.CHF
162
date: !eval "'%s-03-12' %(datetime.now().year+1)"
163
- analytic_id: analytic_account_FP1
164
cost_center_id: analytic_account_OC2
165
destination_id: test_destination
167
currency_id: base.CHF
168
date: !eval "'%s-03-12' %(datetime.now().year+1)"
170
... and another distribution.
172
!record {model: analytic.distribution, id: distribution_test_2}:
174
- analytic_id: analytic_account_FP1
175
cost_center_id: analytic_account_OC2
176
destination_id: test_destination
178
currency_id: base.CHF
179
date: !eval "'%s-03-12' %(datetime.now().year+1)"
180
- analytic_id: analytic_account_FP2
181
cost_center_id: analytic_account_OC2
182
destination_id: test_destination
184
currency_id: base.CHF
185
date: !eval "'%s-03-12' %(datetime.now().year+1)"
186
- analytic_id: analytic_account_FP2
187
cost_center_id: analytic_account_OC1
188
destination_id: test_destination
190
currency_id: base.CHF
191
date: !eval "'%s-03-12' %(datetime.now().year+1)"
193
I overwrite periods to have the right number and open them
195
!python {model: account.period}: |
197
period_ids = [ref('account_period_mar0')]
198
for p in self.browse(cr, uid, period_ids):
199
self.write(cr, uid, [p.id], {'number': int(datetime.datetime.strptime(p.date_start, '%Y-%m-%d').strftime('%m'))})
200
self.action_set_state(cr, uid, period_ids, {'state': 'draft'})
202
I create an account move line with all of this.
204
!record {model: account.move.line, id: move_line_test}:
206
journal_id: account_journal_1
207
period_id: account_period_mar0
208
account_id: test_expense
209
currency_id: base.CHF
210
date: !eval "'%s-03-12' %(datetime.now().year+1)"
211
debit_currency: 4242.0
212
analytic_distribution_id: distribution_test
214
I create an account move line with all of this.
216
!record {model: account.move.line, id: move_line_test_2}:
218
journal_id: account_journal_1
219
period_id: account_period_mar0
220
account_id: test_expense
221
currency_id: base.CHF
222
date: !eval "'%s-03-12' %(datetime.now().year+1)"
223
debit_currency: 12500.0
224
analytic_distribution_id: distribution_test_2
227
Analytic lines are created from it
229
!python {model: account.move.line}: |
230
self.create_analytic_lines(cr, uid, [ref("move_line_test"), ref("move_line_test_2")], context={})
233
I create a decision moment
235
!record {model: msf.budget.decision.moment, id: decision1}:
236
name: Decision moment 1
241
!record {model: msf.instance, id: test_instance}:
245
target_cost_center_ids:
246
- cost_center_id: analytic_account_OC1
248
is_top_cost_center: True
249
is_po_fo_cost_center: True
253
I add the instance to the default company
255
!python {model: res.company}: |
256
user = self.pool.get('res.users').browse(cr, uid, uid)
257
if not user.company_id.instance_id:
258
self.write(cr, uid, [uid], {'instance_id': ref("test_instance")})
260
Now that lines are here, time for the budget
262
!record {model: msf.budget, id: budget_test}:
265
fiscalyear_id: account_fiscalyear_fiscalyear0
267
cost_center_id: analytic_account_OC1
268
decision_moment_id: decision1
270
currency_id: base.EUR
275
!record {model: msf.budget.line, id: budget_line_test}:
276
budget_id: budget_test
277
account_id: test_expense
278
destination_id: test_destination
279
budget_values: '[3323232,455,2221,55542,21,555,2113,345,2212,766,33356,222]'
280
line_type: 'destination'
283
Check budget, actual, percentage, balance for the line
285
!python {model: msf.budget.line}: |
286
budget_line = self.browse(cr, uid, ref("budget_line_test"), context={})
287
#assert budget_line.budget_amount == 3421040, ("Not the correct budget amount!")
288
#assert budget_line.actual_amount == 462100.0, ("Not the correct actual amount! %s!=462100.0"%(budget_line.actual_amount,))
289
#assert budget_line.balance == 2958940.0, ("Not the correct balance!")
290
#assert budget_line.percentage == 14.0, ("Not the correct percentage!")