From bebdc2ce03a4c60e94337cf69a12e167a8144d72 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 8 Jul 2016 15:42:29 +0200 Subject: [PATCH] =?utf8?q?Auftrag:=20Projekt=20automatisch=20in=20verkn?= =?utf8?q?=C3=BCpftem=20Pflichtenheft=20eintragen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/Order.pm | 13 +++++++++++++ SL/OE.pm | 25 +++++++++++++++++++++++++ doc/changelog | 3 +++ 3 files changed, 41 insertions(+) diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index eac3ad9db..302a5eacf 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -1702,6 +1702,8 @@ sub save { $self->link_requirement_specs_linking_to_created_from_objects(@converted_from_oe_ids); } + $self->set_project_in_linked_requirement_specs if $self->order->globalproject_id; + $self->save_history('SAVED'); 1; @@ -2328,6 +2330,17 @@ sub link_requirement_specs_linking_to_created_from_objects { } } +sub set_project_in_linked_requirement_specs { + my ($self) = @_; + + my $rs_orders = SL::DB::Manager::RequirementSpecOrder->get_all(where => [ order_id => $self->order->id ]); + foreach my $rs_order (@{ $rs_orders }) { + next if $rs_order->requirement_spec->project_id == $self->order->globalproject_id; + + $rs_order->requirement_spec->update_attributes(project_id => $self->order->globalproject_id); + } +} + 1; __END__ diff --git a/SL/OE.pm b/SL/OE.pm index 266e55793..f3d3d0cd5 100644 --- a/SL/OE.pm +++ b/SL/OE.pm @@ -841,6 +841,12 @@ SQL is_new => $is_new, ); + $self->_set_project_in_linked_requirement_spec( + type => $form->{type}, + project_id => $form->{globalproject_id}, + sales_order_id => $form->{id}, + ); + $main::lxdebug->leave_sub(); return 1; @@ -880,6 +886,25 @@ sub _link_created_sales_order_to_requirement_specs_for_sales_quotations { }); } +sub _set_project_in_linked_requirement_spec { + my ($self, %params) = @_; + + return if $params{type} ne 'sales_order'; + return if !$params{project_id} || !$params{sales_order_id}; + + my $query = <get_standard_dbh, $query, $params{project_id}, $params{sales_order_id}); +} + sub save_periodic_invoices_config { my ($self, %params) = @_; diff --git a/doc/changelog b/doc/changelog index c32820016..3004a0df2 100644 --- a/doc/changelog +++ b/doc/changelog @@ -32,6 +32,9 @@ Kleinere neue Features und Detailverbesserungen: - Pflichtenhefte: wenn man im Workflow vom Pflichtenheft ein neues Angebot anlegt und später von diesem Angebot aus einen Auftrag, so wird auch der Auftrag direkt mit dem Pflichtenheft verknüpft. +- Pflichtenhefte: wenn in einem Auftrag, das mit einem Pflichtenheft + verknüpft ist, ein Projekt ausgewählt, so wird dieses Projekt auch + automatisch beim verknüpften Pflichtenheft eingetragen. Bugfixes (Tracker: https://www.kivitendo.de/redmine): -- 2.20.1