From f769991a4bd3d207cece79bb2cb3fc96cec4602d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Tue, 25 Aug 2020 13:14:30 +0200 Subject: [PATCH] =?utf8?q?FlattenToForm:=20individuelle=20Lieferadresse=20?= =?utf8?q?und=20CVars=20ber=C3=BCcksichtigen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/Helper/FlattenToForm.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/SL/DB/Helper/FlattenToForm.pm b/SL/DB/Helper/FlattenToForm.pm index 9523c3579..7c001af88 100644 --- a/SL/DB/Helper/FlattenToForm.pm +++ b/SL/DB/Helper/FlattenToForm.pm @@ -46,12 +46,20 @@ sub flatten_to_form { _copy($self->$vc, $form, '', '', 0, @vc_fields); _copy($self->$vc, $form, $vc, '', 0, @vc_prefixed_fields); _copy($self->contact, $form, '', '', 0, grep { /^cp_/ } map { $_->name } SL::DB::Contact->meta->columns) if _has($self, 'cp_id'); - _copy($self->shipto, $form, '', '', 0, grep { /^shipto/ } map { $_->name } SL::DB::Shipto->meta->columns) if _has($self, 'shipto_id'); _copy($self->globalproject, $form, 'globalproject', '', 0, qw(number description)) if _has($self, 'globalproject_id'); _copy($self->employee, $form, 'employee_', '', 0, map { $_->name } SL::DB::Employee->meta->columns) if _has($self, 'employee_id'); _copy($self->salesman, $form, 'salesman_', '', 0, map { $_->name } SL::DB::Employee->meta->columns) if _has($self, 'salesman_id'); _copy($self->acceptance_confirmed_by, $form, 'acceptance_confirmed_by_', '', 0, map { $_->name } SL::DB::Employee->meta->columns) if _has($self, 'acceptance_confirmed_by_id'); + # Copy selected shipto to form, if set. Else, copy custom shipto, if set. + my $shipto = _has($self, 'shipto_id') ? $self->shipto + : _has($self, 'custom_shipto') ? $self->custom_shipto + : undef; + if ($shipto) { + _copy($shipto, $form, '', '', 0, grep { m{^shipto(?!_id$)} } map { $_->name } SL::DB::Shipto->meta->columns); + _copy_custom_variables($shipto, $form, 'shiptocvar_', ''); + } + _handle_user_data($self, $form); # company is employee and login independent @@ -132,7 +140,7 @@ sub _copy { sub _copy_custom_variables { my ($src, $form, $prefix, $postfix, $cvar_validity) = @_; - my $obj = (any { ref($src) eq $_ } qw(SL::DB::OrderItem SL::DB::DeliveryOrderItem SL::DB::InvoiceItem SL::DB::Contact)) + my $obj = (any { ref($src) eq $_ } qw(SL::DB::OrderItem SL::DB::DeliveryOrderItem SL::DB::InvoiceItem SL::DB::Contact SL::DB::Shipto)) ? $src : $src->customervendor; -- 2.20.1