@@ -13,34 +13,78 @@ class TestAttributeSetSearchable(BuildViewCase):
1313 def setUpClass (cls ):
1414 super ().setUpClass ()
1515 cls .product_model = cls .env .ref ("product.model_product_template" )
16- cls .attr_set_1 = cls .env .ref ("product_attribute_set.computer_attribute_set" )
17- cls .group_1 = cls .env .ref (
18- "product_attribute_set.computer_technical_attribute_group"
16+
17+ # Create required attribute records directly for test compatibility
18+ cls .group_1 = cls .env ["attribute.group" ].create (
19+ {
20+ "name" : "Technical Group" ,
21+ "model_id" : cls .product_model .id ,
22+ "sequence" : 1 ,
23+ }
24+ )
25+
26+ cls .attr_set_1 = cls .env ["attribute.set" ].create (
27+ {
28+ "name" : "Computer Attribute Set" ,
29+ "model_id" : cls .product_model .id ,
30+ }
31+ )
32+
33+ cls .attr_1 = cls .env ["attribute.attribute" ].create (
34+ {
35+ "nature" : "custom" ,
36+ "field_description" : "Processor" ,
37+ "name" : "x_processor" ,
38+ "attribute_type" : "select" ,
39+ "attribute_group_id" : cls .group_1 .id ,
40+ "attribute_set_ids" : [(4 , cls .attr_set_1 .id )],
41+ "model_id" : cls .product_model .id ,
42+ }
1943 )
20- cls .attr_1 = cls .env .ref ("product_attribute_set.computer_processor_attribute" )
21- cls .attr_2 = cls .env .ref (
22- "product_attribute_set.computer_tech_description_attribute"
44+
45+ cls .attr_2 = cls .env ["attribute.attribute" ].create (
46+ {
47+ "nature" : "custom" ,
48+ "field_description" : "Technical Description" ,
49+ "name" : "x_technical_description" ,
50+ "attribute_type" : "text" ,
51+ "attribute_group_id" : cls .group_1 .id ,
52+ "attribute_set_ids" : [(4 , cls .attr_set_1 .id )],
53+ "model_id" : cls .product_model .id ,
54+ }
2355 )
2456 cls .attr_3 = cls .env ["attribute.attribute" ].create (
2557 {
2658 "nature" : "custom" ,
2759 "field_description" : "Hard Disk" ,
2860 "name" : "x_hard_disk" ,
2961 "attribute_type" : "select" ,
30- "attribute_group_id" : cls .env .ref (
31- "product_attribute_set.computer_technical_attribute_group"
32- ).id ,
62+ "attribute_group_id" : cls .group_1 .id , # Using group created directly
3363 "attribute_set_ids" : [
3464 (
3565 4 ,
36- cls .env . ref ( "product_attribute_set.computer_attribute_set" ). id ,
66+ cls .attr_set_1 . id , # Using the set we created directly
3767 0 ,
3868 )
3969 ],
40- "model_id" : cls .env . ref ( "product.model_product_template" ). id ,
70+ "model_id" : cls .product_model . id , # Using the model we already have
4171 "relation_model_id" : cls .product_model .id ,
4272 }
4373 )
74+ # Create an attribute with domain capabilities for domain validation test
75+ cls .attr_select = cls .env ["attribute.attribute" ].create (
76+ {
77+ "nature" : "custom" ,
78+ "field_description" : "Test Domain Attribute" ,
79+ "name" : "x_test_domain_attr" ,
80+ "attribute_type" : "select" ,
81+ "attribute_group_id" : cls .group_1 .id ,
82+ "attribute_set_ids" : [(4 , cls .attr_set_1 .id )],
83+ "model_id" : cls .product_model .id ,
84+ "relation_model_id" : cls .product_model .id ,
85+ }
86+ )
87+
4488 cls .product_1 = cls .env ["product.template" ].create (
4589 {
4690 "name" : "Test Smart Product" ,
@@ -68,9 +112,14 @@ def test_get_extra_attributes(self):
68112 extra_attrs = self .product_1 .get_extra_attributes ()
69113 self .assertFalse (extra_attrs )
70114 # Assert the method returns only the attributes that are visible in e-com app
71- self .product_1 .x_processor = self .env .ref (
72- "product_attribute_set.computer_processor_attribute_option_1"
115+ # Create a test option for the processor attribute
116+ test_option = self .env ["attribute.option" ].create (
117+ {
118+ "name" : "Intel i7" ,
119+ "attribute_id" : self .attr_1 .id ,
120+ }
73121 )
122+ self .product_1 .x_processor = test_option
74123 self .product_1 .write ({"x_technical_description" : "Fast processor" })
75124 self .attr_1 .write ({"e_com_visibility" : True })
76125 extra_attrs = self .product_1 .get_extra_attributes ()
0 commit comments