From 6ceac83b2ba88ffda97a0bc2fb1faa58d6aad7c6 Mon Sep 17 00:00:00 2001 From: James Fournie Date: Wed, 29 Feb 2012 16:42:10 -0800 Subject: [PATCH] Acq - fix cloning of picklists so that all lineitems are cloned with a 'new' state This prevents duplicated items on purchase orders when the picklists are cloned and other wacky problems. Signed-off-by: Mike Rylander --- .../perlmods/lib/OpenILS/Application/Acq/Order.pm | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm index 0533d50d01..7272f6346c 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Order.pm @@ -2186,19 +2186,22 @@ sub clone_picklist_api { my $li_ids = $e->search_acq_lineitem({picklist => $pl_id}, {idlist => 1}); + # get the current user + my $cloner = $mgr->editor->requestor->id; + for my $li_id (@$li_ids) { - # copy the lineitems - my $li = $e->retrieve_acq_lineitem($li_id); - my $new_li = create_lineitem($mgr, %{$li->to_bare_hash}, picklist => $new_pl->id) or return $e->die_event; + # copy the lineitems' MARC + my $marc = ($e->retrieve_acq_lineitem($li_id))->marc; - my $lid_ids = $e->search_acq_lineitem_detail({lineitem => $li_id}, {idlist => 1}); - for my $lid_id (@$lid_ids) { + # create a skeletal clone of the item + my $li = Fieldmapper::acq::lineitem->new; + $li->creator($cloner); + $li->selector($cloner); + $li->editor($cloner); + $li->marc($marc); - # copy the lineitem details - my $lid = $e->retrieve_acq_lineitem_detail($lid_id); - create_lineitem_detail($mgr, %{$lid->to_bare_hash}, lineitem => $new_li->id) or return $e->die_event; - } + my $new_li = create_lineitem($mgr, %{$li->to_bare_hash}, picklist => $new_pl->id) or return $e->die_event; $mgr->respond; } -- 2.11.0