4
4
from datetime import date , timedelta
5
5
6
6
from odoo .exceptions import UserError
7
+ from odoo .fields import Command
7
8
from odoo .tests import tagged
8
9
9
10
from odoo .addons .account .tests import common
10
11
11
12
12
13
@tagged ("post_install" , "-at_install" )
13
14
class TestJournalLockDate (common .AccountTestInvoicingCommon ):
14
- def setUp (self ):
15
- super ().setUp ()
16
- self .account_move_obj = self .env ["account.move" ]
17
- self .account_move_line_obj = self .env ["account.move.line" ]
18
- self .company_id = self .ref ("base.main_company" )
19
- self .partner = self .browse_ref ("base.res_partner_12" )
20
-
21
- self .account = self .company_data ["default_account_revenue" ]
22
- self .account2 = self .company_data ["default_account_expense" ]
23
- self .journal = self .company_data ["default_journal_bank" ]
15
+ @classmethod
16
+ def setUpClass (cls ):
17
+ super ().setUpClass ()
18
+ cls .account_move_obj = cls .env ["account.move" ]
19
+ cls .account_move_line_obj = cls .env ["account.move.line" ]
20
+ cls .account = cls .company_data ["default_account_revenue" ]
21
+ cls .account2 = cls .company_data ["default_account_expense" ]
22
+ cls .journal = cls .company_data ["default_journal_bank" ]
24
23
25
24
# create a move and post it
26
- self .move = self .account_move_obj .create (
25
+ cls .move = cls .account_move_obj .create (
27
26
{
28
27
"date" : date .today (),
29
- "journal_id" : self .journal .id ,
28
+ "journal_id" : cls .journal .id ,
30
29
"line_ids" : [
31
- (
32
- 0 ,
33
- 0 ,
30
+ Command .create (
34
31
{
35
- "account_id" : self .account .id ,
32
+ "account_id" : cls .account .id ,
36
33
"credit" : 1000.0 ,
37
34
"name" : "Credit line" ,
38
35
},
39
36
),
40
- (
41
- 0 ,
42
- 0 ,
37
+ Command .create (
43
38
{
44
- "account_id" : self .account2 .id ,
39
+ "account_id" : cls .account2 .id ,
45
40
"debit" : 1000.0 ,
46
41
"name" : "Debit line" ,
47
42
},
48
43
),
49
44
],
50
45
}
51
46
)
52
- self .move .action_post ()
47
+ cls .move .action_post ()
53
48
# lock journal, set 'Lock Date for Non-Advisers'
54
- self .journal .period_lock_date = date .today () + timedelta (days = 2 )
49
+ cls .journal .period_lock_date = date .today () + timedelta (days = 2 )
55
50
56
51
def test_journal_lock_date (self ):
57
52
self .env .user .write ({"groups_id" : [(3 , self .ref ("base.group_system" ))]})
@@ -77,18 +72,14 @@ def test_journal_lock_date(self):
77
72
"date" : self .journal .period_lock_date + timedelta (days = 3 ),
78
73
"journal_id" : self .journal .id ,
79
74
"line_ids" : [
80
- (
81
- 0 ,
82
- 0 ,
75
+ Command .create (
83
76
{
84
77
"account_id" : self .account .id ,
85
78
"credit" : 1000.0 ,
86
79
"name" : "Credit line" ,
87
80
},
88
81
),
89
- (
90
- 0 ,
91
- 0 ,
82
+ Command .create (
92
83
{
93
84
"account_id" : self .account2 .id ,
94
85
"debit" : 1000.0 ,
@@ -108,18 +99,14 @@ def test_journal_lock_date(self):
108
99
"date" : self .journal .period_lock_date ,
109
100
"journal_id" : self .journal .id ,
110
101
"line_ids" : [
111
- (
112
- 0 ,
113
- 0 ,
102
+ Command .create (
114
103
{
115
104
"account_id" : self .account .id ,
116
105
"credit" : 1000.0 ,
117
106
"name" : "Credit line" ,
118
107
},
119
108
),
120
- (
121
- 0 ,
122
- 0 ,
109
+ Command .create (
123
110
{
124
111
"account_id" : self .account2 .id ,
125
112
"debit" : 1000.0 ,
@@ -166,18 +153,14 @@ def test_journal_lock_date_adviser(self):
166
153
"date" : self .journal .period_lock_date ,
167
154
"journal_id" : self .journal .id ,
168
155
"line_ids" : [
169
- (
170
- 0 ,
171
- 0 ,
156
+ Command .create (
172
157
{
173
158
"account_id" : self .account .id ,
174
159
"credit" : 1000.0 ,
175
160
"name" : "Credit line" ,
176
161
},
177
162
),
178
- (
179
- 0 ,
180
- 0 ,
163
+ Command .create (
181
164
{
182
165
"account_id" : self .account2 .id ,
183
166
"debit" : 1000.0 ,
0 commit comments