Artikel-Controller: Workflow zu Lieferantenauftrag: Lieferant vorauswählen, …
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 22 Apr 2022 15:21:03 +0000 (17:21 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 25 Apr 2022 08:48:50 +0000 (10:48 +0200)
… wenn es genau einen Lieferanten beim Artikel gibt.

SL/Controller/Part.pm

index 061a532..aae4e53 100644 (file)
@@ -163,11 +163,18 @@ sub action_save {
 sub action_save_and_purchase_order {
   my ($self) = @_;
 
-  delete $::form->{previousform};
+  my $session_value;
+  if (1 == scalar @{$self->part->makemodels}) {
+    my $prepared_form           = Form->new('');
+    $prepared_form->{vendor_id} = $self->part->makemodels->[0]->make;
+    $session_value              = $::auth->save_form_in_session(form => $prepared_form);
+  }
+
   $::form->{callback} = $self->url_for(
     controller   => 'Order',
     action       => 'return_from_create_part',
     type         => 'purchase_order',
+    previousform => $session_value,
   );
 
   $self->_run_action('save');