3
3
4
4
from datetime import datetime , timedelta
5
5
6
+ from odoo .tests import tagged
6
7
from odoo .tests .common import TransactionCase
7
8
8
9
10
+ @tagged ("-at_install" , "post_install" )
9
11
class FSMAccountCase (TransactionCase ):
10
- def setUp (self ):
11
- super (FSMAccountCase , self ).setUp ()
12
- self .Wizard = self .env ["fsm.wizard" ]
13
- self .WorkOrder = self .env ["fsm.order" ]
14
- self .AccountInvoice = self .env ["account.move" ]
15
- self .AccountInvoiceLine = self .env ["account.move.line" ]
12
+ @classmethod
13
+ def setUpClass (cls ):
14
+ super ().setUpClass ()
15
+ if not cls .env .company .chart_template_id :
16
+ # Load a CoA if there's none in current company
17
+ coa = cls .env .ref ("l10n_generic_coa.configurable_chart_template" , False )
18
+ if not coa :
19
+ # Load the first available CoA
20
+ coa = cls .env ["account.chart.template" ].search (
21
+ [("visible" , "=" , True )], limit = 1
22
+ )
23
+ coa .try_loading (company = cls .env .company , install_demo = False )
24
+ cls .Wizard = cls .env ["fsm.wizard" ]
25
+ cls .WorkOrder = cls .env ["fsm.order" ]
26
+ cls .AccountInvoice = cls .env ["account.move" ]
27
+ cls .AccountInvoiceLine = cls .env ["account.move.line" ]
16
28
# create a Res Partner
17
- self .test_partner = self .env ["res.partner" ].create (
29
+ cls .test_partner = cls .env ["res.partner" ].create (
18
30
{"name" : "Test Partner" , "phone" : "123" , "email" : "tp@email.com" }
19
31
)
20
32
# create a Res Partner to be converted to FSM Location/Person
21
- self .test_loc_partner = self .env ["res.partner" ].create (
33
+ cls .test_loc_partner = cls .env ["res.partner" ].create (
22
34
{"name" : "Test Loc Partner" , "phone" : "ABC" , "email" : "tlp@email.com" }
23
35
)
24
- self .test_loc_partner2 = self .env ["res.partner" ].create (
36
+ cls .test_loc_partner2 = cls .env ["res.partner" ].create (
25
37
{"name" : "Test Loc Partner 2" , "phone" : "123" , "email" : "tlp@example.com" }
26
38
)
27
39
# create expected FSM Location to compare to converted FSM Location
28
- self .test_location = self .env ["fsm.location" ].create (
40
+ cls .test_location = cls .env ["fsm.location" ].create (
29
41
{
30
42
"name" : "Test Location" ,
31
43
"phone" : "123" ,
32
44
"email" : "tp@email.com" ,
33
- "partner_id" : self .test_loc_partner .id ,
34
- "owner_id" : self .test_loc_partner .id ,
45
+ "partner_id" : cls .test_loc_partner .id ,
46
+ "owner_id" : cls .test_loc_partner .id ,
35
47
}
36
48
)
37
- self .test_order = self .env ["fsm.order" ].create (
49
+ cls .test_order = cls .env ["fsm.order" ].create (
38
50
{
39
- "location_id" : self .test_location .id ,
51
+ "location_id" : cls .test_location .id ,
40
52
"date_start" : datetime .today (),
41
53
"date_end" : datetime .today () + timedelta (hours = 2 ),
42
54
"request_early" : datetime .today (),
43
55
}
44
56
)
45
- self .test_order2 = self .env ["fsm.order" ].create (
57
+ cls .test_order2 = cls .env ["fsm.order" ].create (
46
58
{
47
- "location_id" : self .test_location .id ,
59
+ "location_id" : cls .test_location .id ,
48
60
"date_start" : datetime .today (),
49
61
"date_end" : datetime .today () + timedelta (hours = 2 ),
50
62
"request_early" : datetime .today (),
51
63
}
52
64
)
53
- company = self .env .user .company_id
54
- self .default_account_revenue = self .env ["account.account" ].search (
65
+ company = cls .env .user .company_id
66
+ cls .default_account_revenue = cls .env ["account.account" ].search (
55
67
[
56
68
("company_id" , "=" , company .id ),
57
69
("account_type" , "=" , "income" ),
@@ -64,9 +76,9 @@ def setUp(self):
64
76
limit = 1 ,
65
77
)
66
78
67
- self .test_invoice = self .env ["account.move" ].create (
79
+ cls .test_invoice = cls .env ["account.move" ].create (
68
80
{
69
- "partner_id" : self .test_partner .id ,
81
+ "partner_id" : cls .test_partner .id ,
70
82
"move_type" : "out_invoice" ,
71
83
"invoice_date" : datetime .today ().date (),
72
84
"invoice_line_ids" : [
@@ -86,23 +98,23 @@ def setUp(self):
86
98
0 ,
87
99
{
88
100
"name" : "line_debit" ,
89
- "account_id" : self .default_account_revenue .id ,
101
+ "account_id" : cls .default_account_revenue .id ,
90
102
},
91
103
),
92
104
(
93
105
0 ,
94
106
0 ,
95
107
{
96
108
"name" : "line_credit" ,
97
- "account_id" : self .default_account_revenue .id ,
109
+ "account_id" : cls .default_account_revenue .id ,
98
110
},
99
111
),
100
112
],
101
113
}
102
114
)
103
- self .test_invoice2 = self .env ["account.move" ].create (
115
+ cls .test_invoice2 = cls .env ["account.move" ].create (
104
116
{
105
- "partner_id" : self .test_partner .id ,
117
+ "partner_id" : cls .test_partner .id ,
106
118
"move_type" : "out_invoice" ,
107
119
"invoice_date" : datetime .today ().date (),
108
120
"invoice_line_ids" : [
0 commit comments