Bug 32782: ERM UNIMARC support

Create the biblio record when a resource is created

Test plan:
Create a new local title and confirm that the Koha bibliographic record
is created correctly.

Signed-off-by: Laurence Rault <laurence.rault@biblibre.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 07e37c5414)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2023-02-01 14:06:30 +01:00 committed by Martin Renvoize
parent 31db36fb34
commit c35d528890
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 14 additions and 6 deletions

View File

@ -21,6 +21,7 @@ use MARC::Record;
use Koha::Database;
use C4::Biblio qw( AddBiblio TransformKohaToMarc );
use Koha::Acquisition::Booksellers;
use Koha::Biblios;
use Koha::ERM::EHoldings::Titles;
@ -47,16 +48,23 @@ sub store {
# FIXME This is terrible and ugly, we need to:
# * Provide a mapping for each attribute of title
# * Deal with marcflavour
# * Create a txn
my $title = $self->title;
my $biblio = $title->biblio_id ? Koha::Biblios->find($title->biblio_id) : undef;
my $marc_record = $biblio ? $biblio->metadata->record : MARC::Record->new;
eval {$marc_record->field('245')->delete_subfield('a');};
$marc_record->add_fields(MARC::Field->new(245, '', '', a => $title->publication_title));
my $biblio =
$title->biblio_id
? Koha::Biblios->find( $title->biblio_id )->unblessed
: {};
my $marc_record = TransformKohaToMarc(
{
%$biblio,
'biblio.title' => $title->publication_title,
}
);
my $biblio_id;
if ( $biblio ) {
if ( %$biblio ) {
$biblio_id = $title->biblio_id;
C4::Biblio::ModBiblio($marc_record, $title->biblio_id, '');
} else {