14
14
class TestAssetNumber (TestAssetManagement ):
15
15
@classmethod
16
16
def setUpClass (cls ):
17
+ """Setup."""
17
18
super ().setUpClass ()
18
19
cls .sequence_asset = cls .env ["ir.sequence" ].create (
19
20
{
@@ -26,7 +27,8 @@ def setUpClass(cls):
26
27
)
27
28
28
29
def test_01_asset_number (self ):
29
- # use sequence number on profile_id
30
+ """Test asset creation with a sequence."""
31
+
30
32
self .car5y .write (
31
33
{
32
34
"use_sequence" : True ,
@@ -55,3 +57,85 @@ def test_01_asset_number(self):
55
57
asset .validate ()
56
58
self .assertTrue (asset .number )
57
59
self .assertEqual (asset .number [:2 ], "AC" )
60
+
61
+ def test_02_asset_number_without_sequence (self ):
62
+ """Test asset creation without a sequence."""
63
+ self .car5y .write (
64
+ {
65
+ "use_sequence" : False ,
66
+ "sequence_id" : self .sequence_asset .id ,
67
+ }
68
+ )
69
+
70
+ asset = self .asset_model .create (
71
+ {
72
+ "name" : "test asset without sequence" ,
73
+ "profile_id" : self .car5y .id ,
74
+ "purchase_value" : 1500 ,
75
+ "salvage_value" : 100 ,
76
+ "date_start" : time .strftime ("%Y-08-01" ),
77
+ "method_time" : "year" ,
78
+ "method" : "degr-linear" ,
79
+ "method_number" : 5 ,
80
+ "method_period" : "year" ,
81
+ "prorata" : False ,
82
+ }
83
+ )
84
+
85
+ asset .validate ()
86
+
87
+ self .assertFalse (
88
+ asset .number ,
89
+ "The asset number should not be generated when sequence is disabled." ,
90
+ )
91
+
92
+ def test_03_xls_fields (self ):
93
+ """Test XLS fields include the number field."""
94
+ acquisition_fields = self .env ["account.asset" ]._xls_acquisition_fields ()
95
+ active_fields = self .env ["account.asset" ]._xls_active_fields ()
96
+ removal_fields = self .env ["account.asset" ]._xls_removal_fields ()
97
+
98
+ self .assertIn (
99
+ "number" ,
100
+ acquisition_fields ,
101
+ "The number field should be included in acquisition fields." ,
102
+ )
103
+ self .assertIn (
104
+ "number" ,
105
+ active_fields ,
106
+ "The number field should be included in active fields." ,
107
+ )
108
+ self .assertIn (
109
+ "number" ,
110
+ removal_fields ,
111
+ "The number field should be included in removal fields." ,
112
+ )
113
+
114
+ def test_04_profile_barcode_type_onchange (self ):
115
+ """Test the onchange logic for barcode_type."""
116
+ self .ict3Y .write (
117
+ {
118
+ "barcode_width" : 350 ,
119
+ "barcode_height" : 75 ,
120
+ }
121
+ )
122
+
123
+ self .ict3Y .barcode_type = "qr"
124
+ self .ict3Y ._onchange_barcode_type ()
125
+ self .assertEqual (
126
+ self .ict3Y .barcode_width , 150 , "QR barcode width should default to 150."
127
+ )
128
+ self .assertEqual (
129
+ self .ict3Y .barcode_height ,
130
+ 75 ,
131
+ "Barcode height should remain unchanged for QR." ,
132
+ )
133
+
134
+ self .ict3Y .barcode_type = "barcode"
135
+ self .ict3Y ._onchange_barcode_type ()
136
+ self .assertEqual (
137
+ self .ict3Y .barcode_width , 300 , "Barcode width should default to 300."
138
+ )
139
+ self .assertEqual (
140
+ self .ict3Y .barcode_height , 75 , "Barcode height should default to 75."
141
+ )
0 commit comments