X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FUnit.pm;h=b133d8f131263cf39e3dea9c4b7da4827cf97c7b;hb=b28b0afc6b991b5050ea39f66fd1870ca27f400f;hp=54b104d4fc7774374963afbd17ef5dafe2d8cdc7;hpb=4c9d45bf6dc8697327cc6e49f94c56426e67354f;p=kivitendo-erp.git diff --git a/SL/DB/Unit.pm b/SL/DB/Unit.pm index 54b104d4f..b133d8f13 100644 --- a/SL/DB/Unit.pm +++ b/SL/DB/Unit.pm @@ -4,10 +4,11 @@ use strict; use SL::DB::MetaSetup::Unit; use SL::DB::Manager::Unit; +use SL::DB::Helper::ActsAsList; __PACKAGE__->meta->add_relationships( base => { - type => 'one to one', + type => 'many to one', class => 'SL::DB::Unit', column_map => { base_unit => 'name' }, }, @@ -26,10 +27,12 @@ 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 }; return [ sort { $a->sortkey <=> $b->sortkey } grep { $_->unit_class->name eq $self->unit_class->name } - @{ SL::DB::Manager::Unit->get_all } + @{ $all_units } ]; }