Skip to content

Commit 86488cb

Browse files
[IMP] stock_inventory_lockdown: add hook to decide what locations are excluded from the lockdown
some companies may don't want to block all inventoty loss locations and some others will want to block other types of locations
1 parent 196766b commit 86488cb

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

stock_inventory_lockdown/models/stock_move_line.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ def _get_dest_locations(self):
1818
self.ensure_one()
1919
return self.move_line_ids.mapped("location_dest_id")
2020

21+
def _location_usage_without_restriction(self, move_line):
22+
return (
23+
move_line.location_dest_id.usage == "inventory"
24+
or move_line.location_id.usage == "inventory"
25+
)
26+
2127
@api.constrains("location_dest_id", "location_id", "state")
2228
def _check_locked_location(self):
2329
for move_line in self.filtered(lambda m: m.state == "done"):
@@ -26,11 +32,8 @@ def _check_locked_location(self):
2632
]._get_locations_open_inventories(
2733
[move_line.location_dest_id.id, move_line.location_id.id]
2834
)
29-
if locked_location_ids and not any(
30-
[
31-
move_line.location_dest_id.usage == "inventory",
32-
move_line.location_id.usage == "inventory",
33-
]
35+
if locked_location_ids and not self._location_usage_without_restriction(
36+
move_line
3437
):
3538
location_names = locked_location_ids.mapped("complete_name")
3639
raise ValidationError(

0 commit comments

Comments
 (0)