mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-16 12:12:53 -06:00
* Store default values from custom fields on newly created module components * Invert if/for lines to avoid repetition
This commit is contained in:
parent
001f06cc9a
commit
cc51e7032b
@ -1277,6 +1277,11 @@ class Module(PrimaryModel, ConfigContextModel):
|
|||||||
if not disable_replication:
|
if not disable_replication:
|
||||||
create_instances.append(template_instance)
|
create_instances.append(template_instance)
|
||||||
|
|
||||||
|
# Set default values for any applicable custom fields
|
||||||
|
if cf_defaults := CustomField.objects.get_defaults_for_model(component_model):
|
||||||
|
for component in create_instances:
|
||||||
|
component.custom_field_data = cf_defaults
|
||||||
|
|
||||||
if component_model is not ModuleBay:
|
if component_model is not ModuleBay:
|
||||||
component_model.objects.bulk_create(create_instances)
|
component_model.objects.bulk_create(create_instances)
|
||||||
# Emit the post_save signal for each newly created object
|
# Emit the post_save signal for each newly created object
|
||||||
|
Loading…
Reference in New Issue
Block a user