From 0fdcea4d5621abeba25c510a1452d3a75cebbad9 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 4 Feb 2014 13:11:01 +0100 Subject: [PATCH] SL::DB::Order: with_transaction anstelle von do_transaction nutzen MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. --- SL/DB/Order.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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; -- 2.20.1