1
1
# Copyright 2019 ACSONE SA/NV
2
2
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
3
3
4
- from odoo .tests .common import TransactionCase
5
4
from odoo .exceptions import ValidationError
5
+ from odoo .tests .common import TransactionCase
6
6
7
7
8
8
class TestReportSubstitute (TransactionCase ):
9
9
def setUp (self ):
10
10
# In the demo file we create a new report for ir.module.module model
11
11
# with a substation rule from the original report action
12
12
super (TestReportSubstitute , self ).setUp ()
13
- self .action_report = self .env .ref (' base.ir_module_reference_print' )
14
- self .res_ids = self .env .ref (' base.module_base' ).ids
13
+ self .action_report = self .env .ref (" base.ir_module_reference_print" )
14
+ self .res_ids = self .env .ref (" base.module_base" ).ids
15
15
self .substitution_rule = self .env .ref (
16
- ' report_substitute.substitution_rule_demo_1'
16
+ " report_substitute.substitution_rule_demo_1"
17
17
)
18
+ self .env .company .external_report_layout_id = self .env .ref (
19
+ "web.external_layout_standard"
20
+ ).id
18
21
19
22
def test_substitution (self ):
20
23
res = str (self .action_report .render (res_ids = self .res_ids )[0 ])
@@ -27,54 +30,52 @@ def test_substitution(self):
27
30
def test_recursive_substitution (self ):
28
31
res = str (self .action_report .render (res_ids = self .res_ids )[0 ])
29
32
self .assertNotIn ('<div class="page">Substitution Report 2</div>' , res )
30
- self .env [' ir.actions.report.substitution.rule' ].create (
33
+ self .env [" ir.actions.report.substitution.rule" ].create (
31
34
{
32
- ' substitution_action_report_id' : self .env .ref (
33
- ' report_substitute.substitution_report_print_2'
35
+ " substitution_action_report_id" : self .env .ref (
36
+ " report_substitute.substitution_report_print_2"
34
37
).id ,
35
- ' action_report_id' : self .env .ref (
36
- ' report_substitute.substitution_report_print'
38
+ " action_report_id" : self .env .ref (
39
+ " report_substitute.substitution_report_print"
37
40
).id ,
38
41
}
39
42
)
40
43
res = str (self .action_report .render (res_ids = self .res_ids )[0 ])
41
44
self .assertIn ('<div class="page">Substitution Report 2</div>' , res )
42
45
43
46
def test_substitution_with_domain (self ):
44
- self .substitution_rule .write ({' domain' : "[('name', '=', 'base')]" })
47
+ self .substitution_rule .write ({" domain" : "[('name', '=', 'base')]" })
45
48
res = str (self .action_report .render (res_ids = self .res_ids )[0 ])
46
49
self .assertIn ('<div class="page">Substitution Report</div>' , res )
47
- self .substitution_rule .write ({' domain' : "[('name', '!=', 'base')]" })
50
+ self .substitution_rule .write ({" domain" : "[('name', '!=', 'base')]" })
48
51
res = str (self .action_report .render (res_ids = self .res_ids )[0 ])
49
52
self .assertNotIn ('<div class="page">Substitution Report</div>' , res )
50
53
51
54
def test_substitution_with_action_dict (self ):
52
55
substitution_report_action = self .env [
53
- 'ir.actions.report'
54
- ].get_substitution_report_action (
55
- self .action_report .read ()[0 ], self .res_ids
56
- )
56
+ "ir.actions.report"
57
+ ].get_substitution_report_action (self .action_report .read ()[0 ], self .res_ids )
57
58
self .assertEqual (
58
- substitution_report_action ['id' ],
59
+ substitution_report_action ["id" ],
59
60
self .substitution_rule .substitution_action_report_id .id ,
60
61
)
61
62
62
63
def test_substitution_with_report_action (self ):
63
64
res = self .action_report .report_action (self .res_ids )
64
65
self .assertEqual (
65
- res [' report_name' ],
66
+ res [" report_name" ],
66
67
self .substitution_rule .substitution_action_report_id .report_name ,
67
68
)
68
69
69
70
def test_substitution_infinite_loop (self ):
70
71
with self .assertRaises (ValidationError ):
71
- self .env [' ir.actions.report.substitution.rule' ].create (
72
+ self .env [" ir.actions.report.substitution.rule" ].create (
72
73
{
73
- ' action_report_id' : self .env .ref (
74
- ' report_substitute.substitution_report_print'
74
+ " action_report_id" : self .env .ref (
75
+ " report_substitute.substitution_report_print"
75
76
).id ,
76
- ' substitution_action_report_id' : self .env .ref (
77
- ' base.ir_module_reference_print'
77
+ " substitution_action_report_id" : self .env .ref (
78
+ " base.ir_module_reference_print"
78
79
).id ,
79
80
}
80
81
)
0 commit comments