Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions stock_inventory_lockdown/models/stock_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ def _get_dest_locations(self):
self.ensure_one()
return self.move_line_ids.mapped("location_dest_id")

def _location_usage_without_restriction(self):
self.ensure_one()
return (
self.location_dest_id.usage == "inventory"
or self.location_id.usage == "inventory"
)

@api.constrains("location_dest_id", "location_id", "state")
def _check_locked_location(self):
for move_line in self.filtered(lambda m: m.state == "done"):
Expand All @@ -26,11 +33,9 @@ def _check_locked_location(self):
]._get_locations_open_inventories(
[move_line.location_dest_id.id, move_line.location_id.id]
)
if locked_location_ids and not any(
[
move_line.location_dest_id.usage == "inventory",
move_line.location_id.usage == "inventory",
]
if (
locked_location_ids
and not move_line._location_usage_without_restriction()
):
location_names = locked_location_ids.mapped("complete_name")
raise ValidationError(
Expand Down