Bug 26082

Summary: Follow up to bug 23463 - need to call Koha::Item store to get itemnumber
Product: Koha Reporter: Colin Campbell <colin.campbell>
Component: AcquisitionsAssignee: Colin Campbell <colin.campbell>
Status: CLOSED FIXED QA Contact: Kyle M Hall (khall) <kyle>
Severity: major    
Priority: P5 - low CC: aleisha, colin.campbell, janet.mcgowan, jonathan.druart, kyle, lucas, martin.renvoize, nick
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.11.00, 20.05.04
Circulation function:
Bug Depends on: 23463    
Bug Blocks: 26438    
Attachments: Patch adding calls to store when new items created so that valid itemnumber is returned
Revised patch to add calls to store when new items are created so that valid itemnumber is returned
Bug 26082: Call store on new items to update itemnumber

Description Colin Campbell 2020-07-29 12:21:53 UTC
As a result of using Koha::Item instead of AddItem processing of Edifact messages are aborting. When calling Koha::Item->new we need to call store in order to have a valid itemnumber returned otherwise the itemnumber is undefined causing subsequent usage of it to abort. A case in Illrequest.pm was picked up in bug 23463 the cases in EDI.pm need to be amended similarly
Comment 1 Colin Campbell 2020-07-29 12:29:50 UTC
Created attachment 107490 [details] [review]
Patch adding calls to store when new items created so that valid itemnumber is returned
Comment 2 Colin Campbell 2020-07-29 13:43:52 UTC
Created attachment 107501 [details] [review]
Revised patch to add calls to store when new items are created so that valid itemnumber is returned


Add an explicit setting of biblioitemnumber to avoid store generating foreign key errors (this also used to be implicit behaviour)
Comment 3 Kyle M Hall (khall) 2020-08-19 14:41:25 UTC
Created attachment 108637 [details] [review]
Bug 26082: Call store on new items to update itemnumber

Need to add call to store to Koha::Item->new so that itemnumber
is returned - otherwise is not defined and causes an error
Bug is a side-effect of Bug 23463 as this was implicitly
done in AddItem

Also set biblioitemnumber explicitly for item adds this also
used to be done explicitly but can now cause an FK error

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 4 Jonathan Druart 2020-08-20 08:21:49 UTC
Those lines are not needed, but won't hurt:
  $item_hash->{biblioitemnumber} = $bib->{biblioitemnumber};

It's handled in Koha::Item->store.

Sorry for having missed that!
Comment 5 Jonathan Druart 2020-08-20 10:34:42 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 6 Martin Renvoize (ashimema) 2020-09-02 08:56:49 UTC
20.05 will need this ;)
Comment 7 Lucas Gass (lukeg) 2020-09-04 16:38:31 UTC
backported to 20.05.x for 20.05.04
Comment 8 Aleisha Amohia 2020-09-10 03:53:23 UTC
missing dependencies, not backported to 19.11.x