X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/2d82392bb18eb578dfab960a6fab4021a270234e..9cb9a44803b42042fbec121e832ca82e29d1c8e4:/SL/Controller/Order.pm diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index fc05b2d16..4227ca036 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -1692,6 +1692,14 @@ sub workflow_sales_or_purchase_order { : $::form->{type} eq sales_order_type() ? purchase_order_type() : ''; + # check for direct delivery + # copy shipto in custom shipto (custom shipto will be copied by new_from() in case) + my $custom_shipto; + if ( $::form->{type} eq sales_order_type() && $destination_type eq purchase_order_type() + && $::form->{use_shipto} && $self->order->shipto) { + $custom_shipto = $self->order->shipto->clone('SL::DB::Order'); + } + $self->order(SL::DB::Order->new_from($self->order, destination_type => $destination_type)); $self->{converted_from_oe_id} = delete $::form->{id}; @@ -1700,6 +1708,15 @@ sub workflow_sales_or_purchase_order { $item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); } + if ($::form->{type} eq sales_order_type() && $destination_type eq purchase_order_type()) { + if ($::form->{use_shipto}) { + $self->order->custom_shipto($custom_shipto) if $custom_shipto; + } else { + # remove any custom shipto if not wanted + $self->order->custom_shipto(SL::DB::Shipto->new(module => 'OE', custom_variables => [])); + } + } + # change form type $::form->{type} = $destination_type; $self->type($self->init_type); @@ -1825,8 +1842,8 @@ sub setup_edit_action_bar { ], action => [ t8('Save and Purchase Order'), - submit => [ '#order_form', { action => "Order/purchase_order" } ], - only_if => (any { $self->type eq $_ } (sales_order_type(), request_quotation_type())), + call => [ 'kivi.Order.purchase_order_check_for_direct_delivery' ], + only_if => (any { $self->type eq $_ } (sales_order_type(), request_quotation_type())), ], action => [ t8('Save and Delivery Order'),