diff --git a/ereuse_devicehub/inventory/forms.py b/ereuse_devicehub/inventory/forms.py index 65d2b5c3..b00d8181 100644 --- a/ereuse_devicehub/inventory/forms.py +++ b/ereuse_devicehub/inventory/forms.py @@ -136,9 +136,13 @@ class FilterForm(FlaskForm): if self.lot_id: self.lot = self.lots.filter(Lot.id == self.lot_id).one() device_ids = (d.id for d in self.lot.devices) - self.devices = Device.query.filter(Device.id.in_(device_ids)) + self.devices = Device.query.filter(Device.id.in_(device_ids)).filter( + Device.binding == None + ) else: - self.devices = Device.query.filter(Device.owner_id == g.user.id) + self.devices = Device.query.filter(Device.owner_id == g.user.id).filter( + Device.binding == None + ) if self.only_unassigned: self.devices = self.devices.filter_by(lots=None)