From: Moritz Bunkus Date: Thu, 9 Jan 2014 11:03:24 +0000 (+0100) Subject: Pflichtenhefte -> Angebote: Eintrag in record_links anlegen X-Git-Tag: release-3.2.0beta~467^2~59 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=85ab58eb1bbdb3fc723bb3ab30e15e150e62556d;p=kivitendo-erp.git Pflichtenhefte -> Angebote: Eintrag in record_links anlegen --- diff --git a/SL/Controller/RequirementSpecOrder.pm b/SL/Controller/RequirementSpecOrder.pm index 0e9785272..07d3e0603 100644 --- a/SL/Controller/RequirementSpecOrder.pm +++ b/SL/Controller/RequirementSpecOrder.pm @@ -63,13 +63,20 @@ sub action_create { # 2. Create actual quotation/order. my $order = $self->create_order(sections => $sections); - $order->save; + $order->db->with_transaction(sub { + $order->save; + + $self->requirement_spec->orders( + @{ $self->requirement_spec->orders }, + SL::DB::RequirementSpecOrder->new(order => $order, version => $self->requirement_spec->version) + ); + $self->requirement_spec->save; + + $self->requirement_spec->link_to_record($order); + }) or do { + $::lxdebug->message(LXDebug::WARN(), "Error creating the order object: $@"); + }; - $self->requirement_spec->orders( - @{ $self->requirement_spec->orders }, - SL::DB::RequirementSpecOrder->new(order => $order, version => $self->requirement_spec->version) - ); - $self->requirement_spec->save; $self->init_requirement_spec; # 3. Notify the user and return to list. @@ -135,7 +142,13 @@ sub action_do_update { $order->orderitems([ @{ $order->orderitems }, @new_orderitems ]) if @new_orderitems; $order->calculate_prices_and_taxes; - $order->save; + + $order->db->with_transaction(sub { + $order->save; + $self->requirement_spec->link_to_record($order); + }) or do { + $::lxdebug->message(LXDebug::WARN(), "Error updating the order object: $@"); + }; $self->init_requirement_spec; diff --git a/SL/DB/RequirementSpec.pm b/SL/DB/RequirementSpec.pm index 9ec553ce9..e1298ec29 100644 --- a/SL/DB/RequirementSpec.pm +++ b/SL/DB/RequirementSpec.pm @@ -8,6 +8,7 @@ use Rose::DB::Object::Helpers; use SL::DB::MetaSetup::RequirementSpec; use SL::DB::Manager::RequirementSpec; +use SL::DB::Helper::LinkedRecords; use SL::Locale::String; use SL::Util qw(_hashify);