5
5
from odoo import exceptions
6
6
from odoo .modules import registry
7
7
from odoo .tests import common
8
+ from odoo .tests .common import Form
8
9
9
10
from ..hooks import uninstall_hook
10
11
@@ -28,24 +29,18 @@ def setUpClass(cls):
28
29
record = cls .env .ref ("chained_swapper.chained_swapper_demo" , False )
29
30
if record :
30
31
record .unlink ()
31
- cls .chained_swapper = cls .env ["chained.swapper" ].create (
32
- {
33
- "name" : "Language" ,
34
- "model_id" : cls .env .ref ("base.model_res_partner" ).id ,
35
- "field_id" : cls .env .ref ("base.field_res_partner__lang" ).id ,
36
- "sub_field_ids" : [(0 , 0 , {"sub_field_chain" : "child_ids.lang" })],
37
- "constraint_ids" : [
38
- (
39
- 0 ,
40
- 0 ,
41
- {
42
- "name" : "Only parent company" ,
43
- "expression" : "bool(records.mapped('parent_id'))" ,
44
- },
45
- )
46
- ],
47
- }
48
- )
32
+
33
+ chained_swapper_form = Form (cls .env ["chained.swapper" ])
34
+ chained_swapper_form .name = "Language"
35
+ chained_swapper_form .model_id = cls .env .ref ("base.model_res_partner" )
36
+ chained_swapper_form .field_id = cls .env .ref ("base.field_res_partner__lang" )
37
+ with chained_swapper_form .sub_field_ids .new () as sub_field_form :
38
+ sub_field_form .sub_field_chain = "child_ids.lang"
39
+ with chained_swapper_form .constraint_ids .new () as constraint_form :
40
+ constraint_form .name = "Only parent company"
41
+ constraint_form .expression = "bool(records.mapped('parent_id'))"
42
+
43
+ cls .chained_swapper = chained_swapper_form .save ()
49
44
cls .chained_swapper .add_action ()
50
45
51
46
def test_create_unlink_action (self ):
0 commit comments