DeliveryOrder: transfer_inventory fixes
authorSven Schöling <s.schoeling@googlemail.com>
Sun, 5 Dec 2021 23:33:21 +0000 (00:33 +0100)
committerJan Büren <jan@kivitendo.de>
Mon, 14 Feb 2022 14:02:19 +0000 (15:02 +0100)
SL/Controller/DeliveryOrder.pm
SL/DB/DeliveryOrderItem.pm
SL/DB/Inventory.pm

index 1806c24..d7a0c90 100644 (file)
@@ -1059,9 +1059,9 @@ sub action_transfer_stock {
     $self->js->flash("error", t8("No stock to transfer"))->render;
   }
 
-  SL::DB->with_transaction(sub {
+  SL::DB->client->with_transaction(sub {
     $_->save for @transfer_requests;
-    $self->order->update_attributes(deliverd => 1);
+    $self->order->update_attributes(delivered => 1);
   });
 
   $self->js->flash("info", t8("Stock transfered"))->render;
index a42dad5..7850a64 100644 (file)
@@ -51,7 +51,7 @@ sub displayable_delivery_order_info {
 sub effective_project {
   my ($self) = @_;
 
-  $self->project // $self->delivery_order->project;
+  $self->project // $self->delivery_order->globalproject;
 }
 
 __END__
index 3dccdd5..8557719 100644 (file)
@@ -33,15 +33,14 @@ sub new_from {
 }
 
 sub new_from_delivery_order_stock {
-  my ($stock) = @_;
+  my ($class, $stock) = @_;
 
   my $project = $stock->delivery_order_item->effective_project;
 
-  return __PACKAGE__->new(
+  return $class->new(
     delivery_order_items_stock_id => $stock->id,
     parts_id                      => $stock->delivery_order_item->parts_id,
-    qty                           => $stock->unit->convert_to($stock->qty => $stock->delivery_order_item->part->unit_obj),
-    unit                          => $stock->delivery_order_item->part->unit_obj,
+    qty                           => $stock->unit_obj->convert_to($stock->qty => $stock->delivery_order_item->part->unit_obj),
     warehouse_id                  => $stock->warehouse_id,
     bin_id                        => $stock->bin_id,
     chargenumber                  => $stock->chargenumber,