From 0ff17226240249b036073f696ecc6e15017f98be Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 16 Jan 2015 13:34:51 +0100 Subject: [PATCH] =?utf8?q?LinkedRecords:=20with=5Fobjects=20erlauben=20f?= =?utf8?q?=C3=BCr=20shipped=5Fqty?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/Helper/LinkedRecords.pm | 7 ++++++- SL/DB/OrderItem.pm | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/SL/DB/Helper/LinkedRecords.pm b/SL/DB/Helper/LinkedRecords.pm index c7de25b74..2ed5d2036 100644 --- a/SL/DB/Helper/LinkedRecords.pm +++ b/SL/DB/Helper/LinkedRecords.pm @@ -85,7 +85,12 @@ sub _linked_records_implementation { $_->{_record_link_direction} = $wanted; $_->{_record_link} = $link; $_ - } @{ $manager_class->get_all(query => [ id => $link->$sub_wanted_id, @get_objects_query ]) }; + } @{ + $manager_class->get_all( + query => [ id => $link->$sub_wanted_id, @get_objects_query ], + (with_objects => $params{with_objects}) x !!$params{with_objects}, + ) + }; }; # If no 'via' is given then use a simple(r) method for querying the wanted objects. diff --git a/SL/DB/OrderItem.pm b/SL/DB/OrderItem.pm index d46fdcc36..e7b9179f6 100644 --- a/SL/DB/OrderItem.pm +++ b/SL/DB/OrderItem.pm @@ -33,10 +33,9 @@ sub is_price_update_available { sub shipped_qty { my ($self) = @_; - my $d_orders = $self->order->linked_records(direction => 'to', to => 'SL::DB::DeliveryOrder'); + my $d_orders = $self->order->linked_records(direction => 'to', to => 'SL::DB::DeliveryOrder', with_objects => [ 'orderitems' ]); my @doi = grep { $_->parts_id == $self->parts_id } map { $_->orderitems } @$d_orders; - require SL::AM; return sum(map { AM->convert_unit($_->unit => $self->unit) * $_->qty } @doi); } -- 2.20.1