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 (
29
- {
30
- "name" : "Test Location" ,
31
- "phone" : "123" ,
32
- "email" : "tp@email.com" ,
33
- "partner_id" : self .test_loc_partner .id ,
34
- "owner_id" : self .test_loc_partner .id ,
35
- }
40
+ cls .test_location = (
41
+ cls .env ["fsm.location" ]
42
+ .with_context (default_owner_id = cls .test_loc_partner .id )
43
+ .create (
44
+ {
45
+ "name" : "Test Location" ,
46
+ "phone" : "123" ,
47
+ "email" : "tp@email.com" ,
48
+ "partner_id" : cls .test_loc_partner .id ,
49
+ }
50
+ )
36
51
)
37
- self .test_order = self .env ["fsm.order" ].create (
52
+ cls .test_order = cls .env ["fsm.order" ].create (
38
53
{
39
- "location_id" : self .test_location .id ,
54
+ "location_id" : cls .test_location .id ,
40
55
"date_start" : datetime .today (),
41
56
"date_end" : datetime .today () + timedelta (hours = 2 ),
42
57
"request_early" : datetime .today (),
43
58
}
44
59
)
45
- self .test_order2 = self .env ["fsm.order" ].create (
60
+ cls .test_order2 = cls .env ["fsm.order" ].create (
46
61
{
47
- "location_id" : self .test_location .id ,
62
+ "location_id" : cls .test_location .id ,
48
63
"date_start" : datetime .today (),
49
64
"date_end" : datetime .today () + timedelta (hours = 2 ),
50
65
"request_early" : datetime .today (),
51
66
}
52
67
)
53
- company = self .env .user .company_id
54
- self .default_account_revenue = self .env ["account.account" ].search (
68
+ company = cls .env .user .company_id
69
+ cls .default_account_revenue = cls .env ["account.account" ].search (
55
70
[
56
71
("company_id" , "=" , company .id ),
57
72
("account_type" , "=" , "income" ),
@@ -64,9 +79,9 @@ def setUp(self):
64
79
limit = 1 ,
65
80
)
66
81
67
- self .test_invoice = self .env ["account.move" ].create (
82
+ cls .test_invoice = cls .env ["account.move" ].create (
68
83
{
69
- "partner_id" : self .test_partner .id ,
84
+ "partner_id" : cls .test_partner .id ,
70
85
"move_type" : "out_invoice" ,
71
86
"invoice_date" : datetime .today ().date (),
72
87
"invoice_line_ids" : [
@@ -86,23 +101,23 @@ def setUp(self):
86
101
0 ,
87
102
{
88
103
"name" : "line_debit" ,
89
- "account_id" : self .default_account_revenue .id ,
104
+ "account_id" : cls .default_account_revenue .id ,
90
105
},
91
106
),
92
107
(
93
108
0 ,
94
109
0 ,
95
110
{
96
111
"name" : "line_credit" ,
97
- "account_id" : self .default_account_revenue .id ,
112
+ "account_id" : cls .default_account_revenue .id ,
98
113
},
99
114
),
100
115
],
101
116
}
102
117
)
103
- self .test_invoice2 = self .env ["account.move" ].create (
118
+ cls .test_invoice2 = cls .env ["account.move" ].create (
104
119
{
105
- "partner_id" : self .test_partner .id ,
120
+ "partner_id" : cls .test_partner .id ,
106
121
"move_type" : "out_invoice" ,
107
122
"invoice_date" : datetime .today ().date (),
108
123
"invoice_line_ids" : [
0 commit comments