From cb23049882a27902f531f7cd06903626fee429e8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 26 Nov 2019 09:44:40 +0100 Subject: [PATCH] Bug 24111: Remove incorrect "Can't create any orders" alert It happens to see "You can't create any orders unless you first define a budget and a fund" when adding a new order. The test on neworderbiblio.pl is not the same as other pages. We should test if the logged in user can use the budget, not if they are the owner. Test plan: 0/ Add an owner to all of your funds 1/ Create an order from an existing record => Without this patch you should see the alert at the bottom of the result list => With this patch applied you should not see it QA will compare with the 2 other occurrences, in acqui/basket.pl and acqui/booksellers.pl --- acqui/neworderbiblio.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/acqui/neworderbiblio.pl b/acqui/neworderbiblio.pl index 0bd6c7e098..6a2d0f013b 100755 --- a/acqui/neworderbiblio.pl +++ b/acqui/neworderbiblio.pl @@ -63,7 +63,7 @@ use C4::Biblio; use C4::Auth; use C4::Output; use C4::Koha; -use C4::Budgets qw/ GetBudgetHierarchy /; +use C4::Budgets qw/ GetBudgetHierarchy CanUserUseBudget /; use C4::Languages qw(getlanguage); use Koha::Acquisition::Booksellers; @@ -87,7 +87,7 @@ my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid ); my $lang = C4::Languages::getlanguage($input); # getting the template -my ( $template, $loggedinuser, $cookie ) = get_template_and_user( +my ( $template, $loggedinuser, $cookie, $userflags ) = get_template_and_user( { template_name => "acqui/neworderbiblio.tt", query => $input, @@ -141,12 +141,14 @@ foreach my $result ( @{$marcresults} ) { } my $patron = Koha::Patrons->find( $loggedinuser ); -my $budgets = GetBudgetHierarchy(q{},$patron->branchcode,$patron->borrowernumber); +my $budgets = GetBudgetHierarchy; my $has_budgets = 0; foreach my $r (@{$budgets}) { if (!defined $r->{budget_amount} || $r->{budget_amount} == 0) { next; } + next unless (CanUserUseBudget($loggedinuser, $r, $userflags)); + $has_budgets = 1; last; } -- 2.11.0