6
6
7
7
@tagged ("-at_install" , "post_install" )
8
8
class TestAccountChartUpdateCommon (common .TransactionCase ):
9
- @classmethod
10
- def _create_xml_id (cls , record ):
11
- return cls .env ["ir.model.data" ].create (
12
- {
13
- "module" : "account_chart_update" ,
14
- "name" : f"{ record ._table } -{ record .id } " ,
15
- "model" : record ._name ,
16
- "res_id" : record .id ,
17
- }
18
- )
19
-
20
- @classmethod
21
- def _create_account_tmpl (cls , name , code , account_type , chart_template ):
22
- record = cls .env ["account.account.template" ].create (
23
- {
24
- "name" : name ,
25
- "code" : code ,
26
- "account_type" : account_type ,
27
- "chart_template_id" : chart_template and chart_template .id ,
28
- }
29
- )
30
- cls ._create_xml_id (record )
31
- return record
32
-
33
- @classmethod
34
- def _create_tax_tmpl (cls , name , chart_template ):
35
- record = cls .env ["account.tax.template" ].create (
36
- {
37
- "name" : name ,
38
- "amount" : 0 ,
39
- "chart_template_id" : chart_template .id ,
40
- "tax_group_id" : cls .env .ref ("account.tax_group_taxes" ).id ,
41
- "refund_repartition_line_ids" : [
42
- (0 , 0 , {"repartition_type" : "base" , "factor_percent" : 100.0 }),
43
- (0 , 0 , {"repartition_type" : "tax" , "factor_percent" : 100.0 }),
44
- (0 , 0 , {"repartition_type" : "tax" , "factor_percent" : 100.0 }),
45
- ],
46
- "invoice_repartition_line_ids" : [
47
- (0 , 0 , {"repartition_type" : "base" , "factor_percent" : 100.0 }),
48
- (0 , 0 , {"repartition_type" : "tax" , "factor_percent" : 100.0 }),
49
- (0 , 0 , {"repartition_type" : "tax" , "factor_percent" : 100.0 }),
50
- ],
51
- }
52
- )
53
- cls ._create_xml_id (record )
54
- return record
55
-
56
- def _create_tax_template_with_account (self , name , chart_template , account ):
57
- record = self .env ["account.tax.template" ].create (
58
- {
59
- "name" : name ,
60
- "amount" : 0 ,
61
- "chart_template_id" : chart_template .id ,
62
- "tax_group_id" : self .env .ref ("account.tax_group_taxes" ).id ,
63
- "refund_repartition_line_ids" : [
64
- (0 , 0 , {"repartition_type" : "base" , "factor_percent" : 100.0 }),
65
- (
66
- 0 ,
67
- 0 ,
68
- {
69
- "repartition_type" : "tax" ,
70
- "factor_percent" : 100.0 ,
71
- "account_id" : account .id ,
72
- },
73
- ),
74
- ],
75
- "invoice_repartition_line_ids" : [
76
- (0 , 0 , {"repartition_type" : "base" , "factor_percent" : 100.0 }),
77
- (
78
- 0 ,
79
- 0 ,
80
- {
81
- "repartition_type" : "tax" ,
82
- "factor_percent" : 100.0 ,
83
- "account_id" : account .id ,
84
- },
85
- ),
86
- ],
87
- }
88
- )
89
- self ._create_xml_id (record )
90
- return record
91
-
92
- @classmethod
93
- def _create_fp_tmpl (cls , name , chart_template ):
94
- record = cls .env ["account.fiscal.position.template" ].create (
95
- {"name" : name , "chart_template_id" : chart_template .id }
96
- )
97
- cls ._create_xml_id (record )
98
- return record
99
-
100
9
def _get_model_data (self , record ):
101
10
return self .env ["ir.model.data" ].search (
102
11
[("model" , "=" , record ._name ), ("res_id" , "=" , record .id )]
@@ -115,82 +24,28 @@ def setUpClass(cls):
115
24
tracking_disable = True ,
116
25
)
117
26
)
118
- cls .account_template = cls ._create_account_tmpl (
119
- "Test" , "100000" , "income" , False
120
- )
121
- cls .chart_template = cls .env ["account.chart.template" ].create (
122
- {
123
- "name" : "Test account_chart_update chart" ,
124
- "currency_id" : cls .env .ref ("base.EUR" ).id ,
125
- "code_digits" : 6 ,
126
- "cash_account_code_prefix" : "570" ,
127
- "bank_account_code_prefix" : "572" ,
128
- "transfer_account_code_prefix" : "100000" ,
129
- "property_account_receivable_id" : cls .account_template .id ,
130
- "property_account_payable_id" : cls .account_template .id ,
131
- "property_account_expense_categ_id" : cls .account_template .id ,
132
- "property_account_income_categ_id" : cls .account_template .id ,
133
- }
134
- )
135
- cls .account_template .chart_template_id = cls .chart_template .id
136
- cls .account_template_pl = cls ._create_account_tmpl (
137
- "Undistributed Profits/Losses" ,
138
- "999999" ,
139
- "equity" ,
140
- cls .chart_template ,
141
- )
142
- cls .tax_template = cls ._create_tax_tmpl ("Test tax" , cls .chart_template )
143
- cls .fp_template = cls ._create_fp_tmpl ("Test fp" , cls .chart_template )
144
- cls .fp_template_tax = cls .env ["account.fiscal.position.tax.template" ].create (
145
- {"tax_src_id" : cls .tax_template .id , "position_id" : cls .fp_template .id }
146
- )
147
- cls ._create_xml_id (cls .fp_template_tax )
148
- cls .fp_template_account = cls .env [
149
- "account.fiscal.position.account.template"
150
- ].create (
151
- {
152
- "account_src_id" : cls .account_template .id ,
153
- "account_dest_id" : cls .account_template .id ,
154
- "position_id" : cls .fp_template .id ,
155
- }
156
- )
157
- cls ._create_xml_id (cls .fp_template_account )
158
- cls .tax_group = cls .env ["account.tax.group" ].create ({"name" : "Test tax group" })
159
- cls .account_tag_1 = cls .env ["account.account.tag" ].create (
160
- {"name" : "Test account tag 1" }
161
- )
162
- cls .account_tag_2 = cls .env ["account.account.tag" ].create (
163
- {"name" : "Test account tag 2" }
164
- )
165
27
cls .company = cls .env ["res.company" ].create (
166
28
{
167
29
"name" : "Test account_chart_update company" ,
168
- "currency_id" : cls .chart_template .currency_id .id ,
169
- "country_id" : cls .env .ref ("base.es" ).id ,
30
+ "country_id" : cls .env .ref ("base.us" ).id ,
170
31
}
171
32
)
172
- chart_by_company_user = cls .chart_template .with_company (cls .company )
173
- chart_by_company_user .try_loading ()
174
- cls .tax = cls .env ["account.tax" ].search (
33
+ template = cls .env ["account.chart.template" ]
34
+ template .try_loading ("generic_coa" , cls .company )
35
+ cls .chart_template_data = template ._get_chart_template_data ("generic_coa" )
36
+ # We delete the records so that we can later delete the linked data
37
+ moves = cls .env ["account.move" ].search (
175
38
[
176
- ("name" , "=" , cls .tax_template .name ),
177
39
("company_id" , "=" , cls .company .id ),
178
40
]
179
41
)
180
- cls .account = cls .env ["account.account" ].search (
181
- [
182
- ("code" , "=" , cls .account_template .code ),
183
- ("company_id" , "=" , cls .company .id ),
184
- ]
185
- )
186
- cls .fp = cls .env ["account.fiscal.position" ].search (
187
- [("name" , "=" , cls .fp_template .name ), ("company_id" , "=" , cls .company .id )]
188
- )
189
- # Prepare wizard values
42
+ moves .filtered (lambda x : x .state == "posted" ).button_draft ()
43
+ moves .unlink ()
44
+ # Prepare wizard
190
45
cls .wizard_obj = cls .env ["wizard.update.charts.accounts" ]
191
46
cls .wizard_vals = {
192
47
"company_id" : cls .company .id ,
193
- "chart_template_id " : cls . chart_template . id ,
48
+ "chart_template " : "generic_coa" ,
194
49
"code_digits" : 6 ,
195
50
"lang" : "en_US" ,
196
51
}
0 commit comments