fix(champ): fill stable_id and stream when cloning from old champs

This commit is contained in:
Paul Chavard 2024-03-18 20:04:53 +01:00
parent 4412aa7d9c
commit a962e2d94e

View file

@ -226,6 +226,10 @@ class Champ < ApplicationRecord
relationships = fork || !private? ? [:etablissement, :geo_areas] : []
deep_clone(only: champ_attributes + value_attributes, include: relationships, validate: !fork) do |original, kopy|
if original.is_a?(Champ)
kopy.write_attribute(:stable_id, original.stable_id)
kopy.write_attribute(:stream, 'main')
end
ClonePiecesJustificativesService.clone_attachments(original, kopy)
end
end