Adding ONUDevice deletion check
Change-Id: Ic44c6b31be422cd13fc1fc219873e397ae94dc48
diff --git a/xos/synchronizer/models/models.py b/xos/synchronizer/models/models.py
index 3cd13f4..380d44c 100644
--- a/xos/synchronizer/models/models.py
+++ b/xos/synchronizer/models/models.py
@@ -129,6 +129,13 @@
class Meta:
proxy = True
+ def delete(self, *args, **kwargs):
+
+ if len(self.volt_service_instances.all()) > 0:
+ raise XOSValidationError('ONU "%s" can\'t be deleted as it has subscribers associated with it' % self.serial_number)
+
+ super(ONUDevice, self).delete(*args, **kwargs)
+
class PONONUPort(PONONUPort_decl):
class Meta:
proxy = True