From: Bernd Bleßmann Date: Mon, 6 Aug 2018 14:24:14 +0000 (+0200) Subject: Workflow VK-Rechnung->Auftrag auf neuen Controller bei experimentellen Features X-Git-Tag: release-3.5.4~321 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=9aa58dc1c8cf72ad95a90688ae2245abe589dd78;p=kivitendo-erp.git Workflow VK-Rechnung->Auftrag auf neuen Controller bei experimentellen Features --- diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm index 9c1d77366..901cc0e97 100644 --- a/SL/Controller/Order.pm +++ b/SL/Controller/Order.pm @@ -72,7 +72,23 @@ sub action_add { sub action_edit { my ($self) = @_; - $self->load_order; + if ($::form->{id}) { + $self->load_order; + + } else { + # this is to edit an order from an unsaved order object + + # set item ids to new fake id, to identify them as new items + foreach my $item (@{$self->order->items_sorted}) { + $item->{new_fake_id} = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000); + } + # trigger rendering values for second row/longdescription as hidden, + # because they are loaded only on demand. So we need to keep the values + # from the source. + $_->{render_second_row} = 1 for @{ $self->order->items_sorted }; + $_->{render_longdescription} = 1 for @{ $self->order->items_sorted }; + } + $self->recalc(); $self->pre_render(); $self->render( diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index 14b8cf220..bfe2819eb 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -909,6 +909,46 @@ sub validate_items { sub order { $main::lxdebug->enter_sub(); + _order(); + + if ($::instance_conf->get_feature_experimental) { + my $order = _make_record(); + $order->globalproject_id(undef) if !$order->globalproject_id; + $order->payment_id(undef) if !$order->payment_id; + my $row = 1; + foreach my $item (@{$order->items_sorted}) { + $item->custom_variables([]); + + $item->price_factor_id(undef) if !$item->price_factor_id; + $item->project_id(undef) if !$item->project_id; + $item->discount($item->discount/100.0); + + # autovivify all cvars that are not in the form (cvars_by_config can do it). + # workaround to pre-parse number-cvars (parse_custom_variable_values does not parse number values). + foreach my $var (@{ $item->cvars_by_config }) { + my $key = 'ic_cvar_' . $var->config->name . '_' . $row; + $var->unparsed_value($::form->{$key}); + $var->unparsed_value($::form->parse_amount(\%::myconfig, $var->{__unparsed_value})) if ($var->config->type eq 'number' && exists($var->{__unparsed_value})); + } + $item->parse_custom_variable_values; + + $row++; + } + + require SL::Controller::Order; + my $c = SL::Controller::Order->new(order => $order); + $c->action_edit(); + + $main::lxdebug->leave_sub(); + $::dispatcher->end_request; + } + + &display_form; + + $main::lxdebug->leave_sub(); +} + +sub _order { my $form = $main::form; my %myconfig = %main::myconfig; my $locale = $main::locale; @@ -982,9 +1022,6 @@ sub order { } &prepare_order; - &display_form; - - $main::lxdebug->leave_sub(); } sub quotation {