@@ -14,8 +14,101 @@ def setUpClass(cls):
1414 cls .env = cls .env (context = dict (cls .env .context , tracking_disable = True ))
1515 cls .so_model = cls .env ["sale.order" ]
1616 cls .product_set_add = cls .env ["sale.product.set.wizard" ]
17- cls .product_set = cls .env .ref ("product_set.product_set_i5_computer" )
18- # Create a test product and sale order (demo sale.sale_order_6 removed in 19.0)
17+
18+ # Create products for tests (self-contained, no dependency on demo data)
19+ cls .product_a = cls .env ["product.product" ].create (
20+ {"name" : "Test Set Product A" , "type" : "consu" }
21+ )
22+ cls .product_b = cls .env ["product.product" ].create (
23+ {"name" : "Test Set Product B" , "type" : "consu" }
24+ )
25+ cls .product_c = cls .env ["product.product" ].create (
26+ {"name" : "Test Set Product C" , "type" : "consu" }
27+ )
28+ cls .product_service_1 = cls .env ["product.product" ].create (
29+ {"name" : "Test Service Product 1" , "type" : "service" }
30+ )
31+ cls .product_service_2 = cls .env ["product.product" ].create (
32+ {"name" : "Test Service Product 2" , "type" : "service" }
33+ )
34+
35+ # Create product set equivalent to "i5 computer offer" demo data
36+ # Sequences: computer_4=20, computer_1=30, computer_3=50
37+ cls .product_set = cls .env ["product.set" ].create (
38+ {
39+ "name" : "i5 computer offer" ,
40+ "set_line_ids" : [
41+ (
42+ 0 ,
43+ 0 ,
44+ {
45+ "product_id" : cls .product_a .id ,
46+ "quantity" : 2 ,
47+ "sequence" : 20 ,
48+ },
49+ ),
50+ (
51+ 0 ,
52+ 0 ,
53+ {
54+ "product_id" : cls .product_b .id ,
55+ "quantity" : 1 ,
56+ "sequence" : 30 ,
57+ },
58+ ),
59+ (
60+ 0 ,
61+ 0 ,
62+ {
63+ "product_id" : cls .product_c .id ,
64+ "quantity" : 1 ,
65+ "sequence" : 50 ,
66+ },
67+ ),
68+ ],
69+ }
70+ )
71+ # Store references to individual lines (ordered by sequence)
72+ lines = cls .product_set .set_line_ids .sorted ("sequence" )
73+ cls .product_set_line_computer_4 = lines [0 ] # sequence 20
74+ cls .product_set_line_computer_1 = lines [1 ] # sequence 30
75+ cls .product_set_line_computer_3 = lines [2 ] # sequence 50
76+
77+ # Create product set equivalent to "Services" demo data (with section)
78+ cls .product_set_services = cls .env ["product.set" ].create (
79+ {
80+ "name" : "Services" ,
81+ "set_line_ids" : [
82+ (
83+ 0 ,
84+ 0 ,
85+ {
86+ "product_id" : cls .product_service_1 .id ,
87+ "quantity" : 1 ,
88+ },
89+ ),
90+ (
91+ 0 ,
92+ 0 ,
93+ {
94+ "product_id" : cls .product_service_2 .id ,
95+ "quantity" : 1 ,
96+ },
97+ ),
98+ (
99+ 0 ,
100+ 0 ,
101+ {
102+ "display_type" : "line_section" ,
103+ "name" : "Section" ,
104+ "quantity" : 0 ,
105+ },
106+ ),
107+ ],
108+ }
109+ )
110+
111+ # Create a test product and sale order
19112 test_product = cls .env ["product.product" ].create (
20113 {"name" : "Test Product For SO" , "type" : "consu" }
21114 )
@@ -54,12 +147,12 @@ def test_add_set_lines_init(self):
54147 [x .id for x in wiz ._get_lines ()], self .product_set .set_line_ids .ids
55148 )
56149 # Pass via ctx
57- line_ids = self .env . ref ( "product_set. product_set_line_computer_1" ) .ids
150+ line_ids = self .product_set_line_computer_1 .ids
58151 wiz = self ._get_wiz (ctx = dict (product_set_add__set_line_ids = line_ids ))
59152 self .assertEqual (wiz .product_set_line_ids .ids , line_ids )
60153 self .assertEqual ([x .id for x in wiz ._get_lines ()], line_ids )
61154 # Pass at create
62- line_ids = self .env . ref ( "product_set. product_set_line_computer_3" ) .ids
155+ line_ids = self .product_set_line_computer_3 .ids
63156 wiz = self ._get_wiz ()
64157 wiz .product_set_line_ids = line_ids
65158 self .assertEqual (wiz .product_set_line_ids .ids , line_ids )
@@ -86,15 +179,9 @@ def test_add_set(self):
86179 for line in so .order_line :
87180 sequence [line .product_id .id ] = line .sequence
88181 # make sure sale order line sequence keep sequence set on set
89- seq_line1 = sequence .pop (
90- self .env .ref ("product_set.product_set_line_computer_4" ).product_id .id
91- )
92- seq_line2 = sequence .pop (
93- self .env .ref ("product_set.product_set_line_computer_1" ).product_id .id
94- )
95- seq_line3 = sequence .pop (
96- self .env .ref ("product_set.product_set_line_computer_3" ).product_id .id
97- )
182+ seq_line1 = sequence .pop (self .product_set_line_computer_4 .product_id .id )
183+ seq_line2 = sequence .pop (self .product_set_line_computer_1 .product_id .id )
184+ seq_line3 = sequence .pop (self .product_set_line_computer_3 .product_id .id )
98185 self .assertTrue (
99186 max (v for k , v in sequence .items ()) < seq_line1 < seq_line2 < seq_line3
100187 )
@@ -110,15 +197,9 @@ def test_add_set_sequence(self):
110197 sequence = {line .product_id : line .sequence for line in so .order_line }
111198 self .assertEqual (len (so .order_line ), count_lines + 3 )
112199 # make sure sale order line sequence keep sequence set on set
113- seq_line1 = sequence .pop (
114- self .env .ref ("product_set.product_set_line_computer_4" ).product_id
115- )
116- seq_line2 = sequence .pop (
117- self .env .ref ("product_set.product_set_line_computer_1" ).product_id
118- )
119- seq_line3 = sequence .pop (
120- self .env .ref ("product_set.product_set_line_computer_3" ).product_id
121- )
200+ seq_line1 = sequence .pop (self .product_set_line_computer_4 .product_id )
201+ seq_line2 = sequence .pop (self .product_set_line_computer_1 .product_id )
202+ seq_line3 = sequence .pop (self .product_set_line_computer_3 .product_id )
122203 self .assertTrue (
123204 max (v for k , v in sequence .items ()) < seq_line1 < seq_line2 < seq_line3
124205 )
@@ -209,7 +290,7 @@ def test_add_set_section(self):
209290 so = self .so
210291 base_line_ids = so .order_line
211292 count_lines = len (so .order_line )
212- product_set_with_section = self .env . ref ( "product_set. product_set_services" )
293+ product_set_with_section = self .product_set_services
213294 so_set = self .product_set_add .create (
214295 {
215296 "product_set_id" : product_set_with_section .id ,
0 commit comments