@@ -7,51 +7,54 @@ class StockStorageCategory(models.Model):
7
7
8
8
_inherit = "stock.storage.category"
9
9
10
- void_location_ids = fields .Many2many (
10
+ empty_location_ids = fields .Many2many (
11
11
comodel_name = "stock.location" ,
12
- compute = "_compute_void_location_ids " ,
13
- help = "These are the void locations having this storage category" ,
12
+ compute = "_compute_empty_location_ids " ,
13
+ help = "These are the empty locations having this storage category" ,
14
14
)
15
- occupied_location_ids = fields .Many2many (
15
+ filled_location_ids = fields .Many2many (
16
16
comodel_name = "stock.location" ,
17
- compute = "_compute_void_location_ids " ,
18
- help = "These are the void locations having this storage category" ,
17
+ compute = "_compute_empty_location_ids " ,
18
+ help = "These are the filled locations having this storage category" ,
19
19
)
20
- void_location_count = fields .Integer (
21
- compute = "_compute_void_location_ids " ,
22
- search = "_search_void_location_count " ,
23
- help = "This is the number of void locations having this storage category" ,
20
+ empty_location_count = fields .Integer (
21
+ compute = "_compute_empty_location_ids " ,
22
+ search = "_search_empty_location_count " ,
23
+ help = "This is the number of empty locations having this storage category" ,
24
24
)
25
- occupied_location_count = fields .Integer (
26
- compute = "_compute_void_location_ids " ,
25
+ filled_location_count = fields .Integer (
26
+ compute = "_compute_empty_location_ids " ,
27
27
help = "This is the number of occupied locations having this storage category" ,
28
28
)
29
- occupation_rate = fields .Float (
30
- compute = "_compute_void_location_ids " ,
29
+ fill_rate = fields .Float (
30
+ compute = "_compute_empty_location_ids " ,
31
31
)
32
32
33
33
@api .depends ("location_ids.children_ids" )
34
- def _compute_void_location_ids (self ):
34
+ def _compute_empty_location_ids (self ):
35
35
for category in self :
36
36
all_locations = (
37
37
category .location_ids | category .location_ids .children_ids
38
38
).filtered (lambda location : location .usage != "view" )
39
- void_locations = all_locations .filtered (
40
- lambda location : not location .occupied
39
+ # Empty locations are locations empty and being emptied
40
+ # (move qty is done but not yet validated).
41
+ # We don't take into account filled and being filled moves.
42
+ empty_locations = all_locations .filtered (
43
+ lambda location : location .fill_state == "empty"
41
44
)
42
- occupied_locations = all_locations - void_locations
45
+ filled_locations = all_locations - empty_locations
43
46
if all_locations :
44
- occupation_rate = float (
45
- 100 - ((len (void_locations ) / len (all_locations )) * 100 )
47
+ fill_rate = float (
48
+ 100 - ((len (empty_locations ) / len (all_locations )) * 100 )
46
49
)
47
50
else :
48
- occupation_rate = 0.0
51
+ fill_rate = 0.0
49
52
category .update (
50
53
{
51
- "void_location_ids " : void_locations .ids ,
52
- "occupied_location_ids " : occupied_locations .ids ,
53
- "occupied_location_count " : len (occupied_locations ),
54
- "void_location_count " : len (void_locations ),
55
- "occupation_rate " : occupation_rate ,
54
+ "empty_location_ids " : empty_locations .ids ,
55
+ "filled_location_ids " : filled_locations .ids ,
56
+ "filled_location_count " : len (filled_locations ),
57
+ "empty_location_count " : len (empty_locations ),
58
+ "fill_rate " : fill_rate ,
56
59
}
57
60
)
0 commit comments