diff --git a/ereuse_devicehub/inventory/views.py b/ereuse_devicehub/inventory/views.py index 6239d98c..8c841a1e 100644 --- a/ereuse_devicehub/inventory/views.py +++ b/ereuse_devicehub/inventory/views.py @@ -198,6 +198,7 @@ class BindingView(GenericMixin): if device.placeholder: device = device.placeholder.binding + dhid = device.devicehub_id if request.method == 'POST': old_placeholder = device.binding @@ -216,10 +217,11 @@ class BindingView(GenericMixin): if act.device == old_device_placeholder: db.session.delete(act) - db.session.delete(old_device_placeholder) for tag in list(old_device_placeholder.tags): tag.device = placeholder.device + db.session.delete(old_device_placeholder) + device.binding = placeholder db.session.commit() next_url = url_for('inventory.device_details', id=dhid)