X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/9c785acd332352877abd90cd0c79a2fa1ef214a1..cadf8b8bfba4fe1b337761d64999fd37ef40ffb0:/SL/Controller/Part.pm diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index 9458a83f3..23b4eff1e 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -457,20 +457,23 @@ sub action_reorder_items { sub action_warehouse_changed { my ($self) = @_; - $self->warehouse(SL::DB::Manager::Warehouse->find_by_or_create(id => $::form->{warehouse_id})); - die unless ref($self->warehouse) eq 'SL::DB::Warehouse'; - - if ( $self->warehouse->id and @{$self->warehouse->bins} ) { - $self->bin($self->warehouse->bins->[0]); - $self->js - ->html('#bin', $self->build_bin_select) - ->focus('#part_bin_id'); - } else { - # no warehouse was selected, empty the bin field and reset the id - $self->js - ->val('#part_bin_id', undef) - ->html('#bin', ''); - }; + if ($::form->{warehouse_id} ) { + $self->warehouse(SL::DB::Manager::Warehouse->find_by_or_create(id => $::form->{warehouse_id})); + die unless ref($self->warehouse) eq 'SL::DB::Warehouse'; + + if ( $self->warehouse->id and @{$self->warehouse->bins} ) { + $self->bin($self->warehouse->bins->[0]); + $self->js + ->html('#bin', $self->build_bin_select) + ->focus('#part_bin_id'); + return $self->js->render; + } + } + + # no warehouse was selected, empty the bin field and reset the id + $self->js + ->val('#part_bin_id', undef) + ->html('#bin', ''); return $self->js->render; } @@ -895,7 +898,8 @@ sub init_all_units { } sub init_all_payment_terms { - SL::DB::Manager::PaymentTerm->get_all_sorted; + my ($self) = @_; + SL::DB::Manager::PaymentTerm->get_all_sorted(query => [ or => [ id => $self->part->payment_id, obsolete => 0 ] ]); } sub init_all_price_factors {