From 846a3025143c1cf8f7609a611c1b12da7edf1319 Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Mon, 24 Sep 2018 07:45:08 +0000 Subject: [PATCH] Bug 21401: Take transaction library from userenv when not defined Test plan: 1) Apply the patch 2) Run database update 3) prove t/db_dependent/Account.t --- Koha/Account/Line.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Koha/Account/Line.pm b/Koha/Account/Line.pm index 9cf8867..5297867 100644 --- a/Koha/Account/Line.pm +++ b/Koha/Account/Line.pm @@ -37,8 +37,19 @@ Koha::Account::Line - Koha accountline Object class =head2 Class methods +=head3 new + +Creates and returns new object, when there is no branchcode param, it is set to active userenv branchcode + =cut +sub new { + my ($class, $params) = @_; + $params->{ branchcode } //= + defined C4::Context->userenv ? C4::Context->userenv->{branch} : undef; + return $class->SUPER::new($params); +} + =head3 item Return the item linked to this account line if exists -- 2.1.4