@@ -12,12 +12,53 @@ def setUpClass(cls):
1212 super ().setUpClass ()
1313 cls .action_report = cls .env .ref ("base.ir_module_reference_print" )
1414 cls .res_ids = cls .env .ref ("base.module_base" ).ids
15- cls .substitution_rule = cls .env .ref (
16- "report_substitute.substitution_rule_demo_1"
17- )
1815 cls .env .company .external_report_layout_id = cls .env .ref (
1916 "web.external_layout_standard"
2017 ).id
18+ cls .env ["ir.ui.view" ].create (
19+ {
20+ "name" : "report_substitute.substitution_report_test" ,
21+ "type" : "qweb" ,
22+ "arch" : '<t t-name="report_substitute.substitution_report_test">'
23+ ' <div class="page">Substitution Report</div>'
24+ "</t>" ,
25+ }
26+ )
27+ cls .env ["ir.ui.view" ].create (
28+ {
29+ "name" : "report_substitute.substitution_report_2_test" ,
30+ "type" : "qweb" ,
31+ "arch" : '<t t-name="report_substitute.substitution_report_2_test">'
32+ ' <div class="page">Substitution Report 2</div>'
33+ "</t>" ,
34+ }
35+ )
36+ cls .substitution_report = cls .env ["ir.actions.report" ].create (
37+ {
38+ "name" : "Substitution For Technical guide" ,
39+ "model" : "ir.module.module" ,
40+ "report_type" : "qweb-pdf" ,
41+ "report_name" : "report_substitute.substitution_report_test" ,
42+ "report_file" : "report_substitute.substitution_report_test" ,
43+ "binding_type" : "report" ,
44+ }
45+ )
46+ cls .substitution_report_2 = cls .env ["ir.actions.report" ].create (
47+ {
48+ "name" : "Substitution 2 For Technical guide" ,
49+ "model" : "ir.module.module" ,
50+ "report_type" : "qweb-pdf" ,
51+ "report_name" : "report_substitute.substitution_report_2_test" ,
52+ "report_file" : "report_substitute.substitution_report_2_test" ,
53+ "binding_type" : "report" ,
54+ }
55+ )
56+ cls .substitution_rule = cls .env ["ir.actions.report.substitution.rule" ].create (
57+ {
58+ "action_report_id" : cls .action_report .id ,
59+ "substitution_action_report_id" : cls .substitution_report .id ,
60+ }
61+ )
2162
2263 def test_substitution (self ):
2364 res = str (
@@ -44,12 +85,8 @@ def test_recursive_substitution(self):
4485 self .assertNotIn ('<div class="page">Substitution Report 2</div>' , res )
4586 self .env ["ir.actions.report.substitution.rule" ].create (
4687 {
47- "substitution_action_report_id" : self .env .ref (
48- "report_substitute.substitution_report_print_2"
49- ).id ,
50- "action_report_id" : self .env .ref (
51- "report_substitute.substitution_report_print"
52- ).id ,
88+ "substitution_action_report_id" : self .substitution_report_2 .id ,
89+ "action_report_id" : self .substitution_report .id ,
5390 }
5491 )
5592 res = str (
@@ -95,11 +132,7 @@ def test_substitution_infinite_loop(self):
95132 with self .assertRaises (ValidationError ):
96133 self .env ["ir.actions.report.substitution.rule" ].create (
97134 {
98- "action_report_id" : self .env .ref (
99- "report_substitute.substitution_report_print"
100- ).id ,
101- "substitution_action_report_id" : self .env .ref (
102- "base.ir_module_reference_print"
103- ).id ,
135+ "action_report_id" : self .substitution_report .id ,
136+ "substitution_action_report_id" : self .action_report .id ,
104137 }
105138 )
0 commit comments