From 78969decd4c306cd524c94ef4844b20d57129867 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 19 Apr 2017 15:11:41 +0200 Subject: [PATCH] =?utf8?q?Pflichtenhefte:=20bei=20Kunden=C3=A4nderung=20au?= =?utf8?q?ch=20Kunden=20in=20Versionen=20=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/RequirementSpec.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/SL/Controller/RequirementSpec.pm b/SL/Controller/RequirementSpec.pm index ecc8e32f8..d4ecc55b7 100644 --- a/SL/Controller/RequirementSpec.pm +++ b/SL/Controller/RequirementSpec.pm @@ -385,6 +385,7 @@ sub init_include_cvars { sub create_or_update { my $self = shift; my $is_new = !$self->requirement_spec->id; + my $previous_customer_id = $self->requirement_spec->customer_id; my $params = delete($::form->{requirement_spec}) || { }; my $cvars = delete($::form->{cvars}) || { }; @@ -425,6 +426,18 @@ sub create_or_update { $self->requirement_spec($self->copy_source->create_copy(%{ $params })); } else { $self->requirement_spec->save(cascade => 1); + + # If the current requirement spec has versions and the + # customer's been changed, then the customer of all the versions + # has to be changed, too. + if ( !$is_new + && !$self->requirement_spec->is_template + && ($previous_customer_id != $self->requirement_spec->customer_id)) { + SL::DB::Manager::RequirementSpec->update_all( + set => { customer_id => $self->requirement_spec->customer_id }, + where => [ working_copy_id => $self->requirement_spec->id ], + ); + } } 1; })) { -- 2.20.1