From: James Fournie Date: Thu, 1 Mar 2012 00:42:10 +0000 (-0800) Subject: Acq - fix cloning of picklists so that all lineitems are cloned with a 'new' state X-Git-Tag: sprint4-merge-nov22~4316 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6ceac83b2ba88ffda97a0bc2fb1faa58d6aad7c6;p=working%2FEvergreen.git 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 --- 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; }