From bb92c272319880cbcc7161a8fa63fe8c67eb6060 Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Thu, 11 Jul 2024 11:25:17 +0700 Subject: [PATCH] 12826 update rack fields on rack_type edit --- netbox/dcim/models/racks.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/netbox/dcim/models/racks.py b/netbox/dcim/models/racks.py index b5fed7307..e2d48efa2 100644 --- a/netbox/dcim/models/racks.py +++ b/netbox/dcim/models/racks.py @@ -161,6 +161,7 @@ class RackType(PrimaryModel, WeightMixin): raise ValidationError(_("Must specify a unit when setting a maximum weight")) def save(self, *args, **kwargs): + update = self.pk # Store the given max weight (if any) in grams for use in database ordering if self.max_weight and self.weight_unit: @@ -173,6 +174,22 @@ class RackType(PrimaryModel, WeightMixin): self.outer_unit = '' super().save(*args, **kwargs) + if update: + # Update all racks associated with this rack_type + self.instances.all().update( + type=self.type, + width=self.width, + u_height=self.u_height, + starting_unit=self.starting_unit, + desc_units=self.desc_units, + outer_width=self.outer_width, + outer_depth=self.outer_depth, + outer_unit=self.outer_unit, + weight=self.weight, + weight_unit=self.weight_unit, + max_weight=self.max_weight, + mounting_depth=self.mounting_depth + ) @property def units(self):