From: Moritz Bunkus Date: Tue, 4 Feb 2014 12:11:01 +0000 (+0100) Subject: SL::DB::Order: with_transaction anstelle von do_transaction nutzen X-Git-Tag: release-3.2.0beta~491^2~25 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=0fdcea4d5621abeba25c510a1452d3a75cebbad9;p=kivitendo-erp.git SL::DB::Order: with_transaction anstelle von do_transaction nutzen do_transaction startet immer eine Transaktion, auch wenn außen rum schon eine läuft. Damit wird die äußere Transaktion de facto außer Kraft gesetzt. --- diff --git a/SL/DB/Order.pm b/SL/DB/Order.pm index 89f602eb7..8909b7e26 100644 --- a/SL/DB/Order.pm +++ b/SL/DB/Order.pm @@ -130,12 +130,12 @@ sub convert_to_invoice { croak("Conversion to invoices is only supported for sales records") unless $self->customer_id; my $invoice; - if (!$self->db->do_transaction(sub { + if (!$self->db->with_transaction(sub { require SL::DB::Invoice; $invoice = SL::DB::Invoice->new_from($self)->post(%params) || die; $self->link_to_record($invoice); $self->update_attributes(closed => 1); - # die; + 1; })) { return undef; } @@ -147,15 +147,15 @@ sub convert_to_delivery_order { my ($self, %params) = @_; my ($delivery_order, $custom_shipto); - if (!$self->db->do_transaction(sub { + if (!$self->db->with_transaction(sub { require SL::DB::DeliveryOrder; ($delivery_order, $custom_shipto) = SL::DB::DeliveryOrder->new_from($self); $delivery_order->save; $custom_shipto->save if $custom_shipto; $self->link_to_record($delivery_order); - # die; + 1; })) { - return undef; + return wantarray ? () : undef; } return wantarray ? ($delivery_order, $custom_shipto) : $delivery_order;