2
In order to test the account module, I start by creating a new account as inactive
3
I create Asset Account Type.
5
!record {model: account.account.type, id: account_account_type_asset0}:
14
!record {model: account.account, id: account_1}:
18
user_type: account_account_type_asset0
19
inactivation_date: !eval "'%s-01-01' %(datetime.now().year + 2)"
22
I check that the activation date is today
24
!python {model: account.account}: |
25
ac = self.browse(cr, uid, ref("account_1"))
27
from dateutil.relativedelta import relativedelta
28
assert ac.activation_date == (datetime.datetime.today() + relativedelta(months=-3)).strftime('%Y-%m-%d'), "Wrong activation date"
31
I create an analytical journal, ...
33
!record {model: account.analytic.journal, id: analytic_journal_1}:
35
name: Cash Analytic Journal
39
... a journal view ...
41
!record {model: account.journal.view, id: journal_view_1}:
46
!record {model: account.journal, id: account_journal_1}:
51
view_id: journal_view_1
52
analytic_journal_id: analytic_journal_1
53
default_debit_account_id: account_1
54
default_credit_account_id: account_1
58
!record {model: account.fiscalyear, id: account_fiscalyear_fiscalyear0}:
59
code: !eval "'FY%s'% (datetime.now().year + 1)"
60
company_id: base.main_company
61
date_start: !eval "'%s-01-01' %(datetime.now().year + 10)"
62
date_stop: !eval "'%s-12-31' %(datetime.now().year + 10)"
63
name: !eval "'Fiscal Year %s' %(datetime.now().year + 10)"
67
!record {model: account.period, id: account_period_0}:
68
company_id: base.main_company
69
date_start: !eval "'%s-03-01' %(datetime.now().year + 1,)"
70
date_stop: !eval "'%s-03-31' %(datetime.now().year + 1)"
71
fiscalyear_id: account_fiscalyear_fiscalyear0
72
name: !eval "'Mar %s' %(datetime.now().year + 1)"
76
I create an account move line with all of this.
78
!record {model: account.move.line, id: move_line_test}:
80
journal_id: account_journal_1
81
period_id: account_period_0
84
date: !eval "'%s-03-12' %(datetime.now().year + 1)"
87
I change the inactivation date to today (forbidden)
89
!python {model: account.account}: |
92
self.write(cr, uid, ref('account_1'), vals={'inactivation_date': datetime.datetime.now().strftime('%Y-%m-%d')})
93
except Exception as exception:
94
assert exception.value == "You cannot set an inactivity date lower than tomorrow!", "Incative date lower"
97
I change the dates so that activation_date > inactivation_date (forbidden)
99
!python {model: account.account}: |
102
self.write(cr, uid, ref('account_1'), vals={'activation_date': '%s-03-12' %(datetime.datetime.now().year + 1), 'inactivation_date': '%s-03-01' %(datetime.datetime.now().year + 1)})
103
except Exception as exception:
104
assert exception.value == "Activation date must be lower than inactivation date!", "Activation lower"
107
I change the move line date so that it is outside the account's activity period (forbidden)
109
!python {model: account.move.line}: |
112
self.write(cr, uid, ref('move_line_test'), vals={'account_id': ref('account_1'), 'date': '%s-03-01' %(datetime.datetime.now().year + 2)})
113
except Exception as exception:
114
assert exception.value.startswith("The selected account is not active:"), "Date out"