diff --git a/roundabout/builds/views_deployments.py b/roundabout/builds/views_deployments.py index b53ecce9..0f6e49dc 100644 --- a/roundabout/builds/views_deployments.py +++ b/roundabout/builds/views_deployments.py @@ -461,28 +461,29 @@ def form_valid(self, form): self.request.user, ) # generate inventory configevent with default values on deyployed to field - if not item.inventory_configevents.exists(): - config_event, event_added = ConfigEvent.objects.get_or_create( - inventory=item, - config_type="conf", - configuration_date = action_date, - deployment = self.object - ) - _create_action_history(config_event, Action.ADD, self.request.user, data={}) - if item.assembly_part is not None: - if item.assembly_part.assemblypart_configdefaultevents.exists(): - conf_def_event = item.assembly_part.assemblypart_configdefaultevents.first() - names = ConfigName.objects.filter(config_name_event = item.part.part_confignameevents.first(), config_type ='conf') - for name in names: - try: - default_value = ConfigDefault.objects.get(conf_def_event = conf_def_event, config_name = name).default_value - except ConfigDefault.DoesNotExist: - default_value = None - ConfigValue.objects.create( - config_event = config_event, - config_name = name, - config_value = default_value, - ) + if action_type == Action.DEPLOYMENTTOFIELD: + if not item.inventory_configevents.exists(): + config_event, event_added = ConfigEvent.objects.get_or_create( + inventory=item, + config_type="conf", + configuration_date = action_date, + deployment = self.object + ) + _create_action_history(config_event, Action.ADD, self.request.user, data={}) + if item.assembly_part is not None: + if item.assembly_part.assemblypart_configdefaultevents.exists(): + conf_def_event = item.assembly_part.assemblypart_configdefaultevents.first() + names = ConfigName.objects.filter(config_name_event = item.part.part_confignameevents.first(), config_type ='conf') + for name in names: + try: + default_value = ConfigDefault.objects.get(conf_def_event = conf_def_event, config_name = name).default_value + except ConfigDefault.DoesNotExist: + default_value = None + ConfigValue.objects.create( + config_event = config_event, + config_name = name, + config_value = default_value, + )