Bug 6104: Modify item looses branch
[koha.git] / cataloguing / additem.pl
index c5dd7d9..e2dfc02 100755 (executable)
@@ -150,7 +150,7 @@ sub generate_subfield_form {
                 foreach my $thisbranch (@$branches) {
                     push @authorised_values, $thisbranch->{value};
                     $authorised_lib{$thisbranch->{value}} = $thisbranch->{branchname};
-                    $value = $thisbranch->{value} if $thisbranch->{selected};
+                    $value = $thisbranch->{value} if $thisbranch->{selected} && !$value;
                 }
             }
             elsif ( $subfieldlib->{authorised_value} eq "itemtypes" ) {
@@ -570,7 +570,7 @@ my $onlymine = C4::Context->preference('IndependantBranches') &&
                C4::Context->userenv                           && 
                C4::Context->userenv->{flags}!=1               && 
                C4::Context->userenv->{branch};
-my $branches = GetBranchesLoop(undef,$onlymine);  # build once ahead of time, instead of multiple times later.
+my $branches = GetBranchesLoop(C4::Context->userenv->{branch},$onlymine);  # build once ahead of time, instead of multiple times later.
 
 # We generate form, from actuel record
 my @fields;