Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2561 from ekylibre/debug/fix-two-clicks-intervent…
…ion-creation

Add a default value of 1 for quantity_population of InterventionOutput
  • Loading branch information
Aquaj committed Jul 3, 2019
2 parents 0ca3e8a + 42d403d commit 6390464
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/models/intervention_output.rb
Expand Up @@ -63,6 +63,12 @@ class InterventionOutput < InterventionProductParameter
has_one :product_movement, as: :originator, dependent: :destroy
validates :variant, :quantity_population, presence: true

after_initialize do
next if persisted?

self.quantity_population ||= 1
end

after_save do
unless destroyed?
output = product
Expand Down

0 comments on commit 6390464

Please sign in to comment.