From: Moritz Bunkus Date: Wed, 30 Jul 2014 12:37:38 +0000 (+0200) Subject: SL::DB::Unit::compatible_units: alle Einheiten gecachet laden X-Git-Tag: release-3.2.0beta~334 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=4bc8abba0059b4c7a490a43d1eebfb7a3b4e8647;p=kivitendo-erp.git SL::DB::Unit::compatible_units: alle Einheiten gecachet laden --- diff --git a/SL/DB/Manager/Unit.pm b/SL/DB/Manager/Unit.pm index f081af49e..673fcb060 100644 --- a/SL/DB/Manager/Unit.pm +++ b/SL/DB/Manager/Unit.pm @@ -41,4 +41,9 @@ sub convertible_to_filter { return ("${prefix}name" => [ map { $_->name } @{ $unit->convertible_units } ]); } +sub all_units { + my ($class) = @_; + $::request->cache('all_units')->{sorted} //= $class->get_all_sorted; +} + 1; diff --git a/SL/DB/Unit.pm b/SL/DB/Unit.pm index e8d260c67..900558fbd 100644 --- a/SL/DB/Unit.pm +++ b/SL/DB/Unit.pm @@ -27,8 +27,8 @@ sub unit_class { sub convertible_units { my $self = shift; - my $all_units = scalar(@_) && (ref($_[0]) eq 'ARRAY') ? $_[0] : \@_; - $all_units = SL::DB::Manager::Unit->get_all if !@{ $all_units }; + my $all_units = scalar(@_) && (ref($_[0]) eq 'ARRAY') ? $_[0] : [ @_ ]; + $all_units = SL::DB::Manager::Unit->all_units if ! @{ $all_units }; return [ sort { $a->sortkey <=> $b->sortkey } grep { $_->unit_class->name eq $self->unit_class->name }