DeliveryPlan: Bei Umwandlung Typ an new_from geben
authorSven Schöling <s.schoeling@googlemail.com>
Fri, 10 Dec 2021 12:54:41 +0000 (13:54 +0100)
committerJan Büren <jan@kivitendo.de>
Mon, 14 Feb 2022 14:02:19 +0000 (15:02 +0100)
SL/Controller/DeliveryOrder.pm

index d7a0c90..a0d9c19 100644 (file)
@@ -18,6 +18,7 @@ use SL::DB::History;
 use SL::DB::Order;
 use SL::DB::Default;
 use SL::DB::Unit;
+use SL::DB::Order;
 use SL::DB::Part;
 use SL::DB::PartClassification;
 use SL::DB::PartsGroup;
@@ -85,7 +86,11 @@ sub action_add_from_order {
   # this interfers with init_order
   $self->{converted_from_oe_id} = delete $::form->{id};
 
-  # TODO copy data and remember to link them on save
+  $self->type_data->validate($::form->{type});
+
+  my $order = SL::DB::Order->new(id => $self->{converted_from_oe_id})->load;
+
+  $self->order(SL::DB::DeliveryOrder->new_from($order, type => $::form->{type}));
 
   $self->action_add;
 }