From e73048f97f59434cce3d9deca211017828def9e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Mon, 6 Dec 2021 00:33:21 +0100 Subject: [PATCH] DeliveryOrder: transfer_inventory fixes --- SL/Controller/DeliveryOrder.pm | 4 ++-- SL/DB/DeliveryOrderItem.pm | 2 +- SL/DB/Inventory.pm | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/SL/Controller/DeliveryOrder.pm b/SL/Controller/DeliveryOrder.pm index 1806c245f..d7a0c90b3 100644 --- a/SL/Controller/DeliveryOrder.pm +++ b/SL/Controller/DeliveryOrder.pm @@ -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; diff --git a/SL/DB/DeliveryOrderItem.pm b/SL/DB/DeliveryOrderItem.pm index a42dad510..7850a6445 100644 --- a/SL/DB/DeliveryOrderItem.pm +++ b/SL/DB/DeliveryOrderItem.pm @@ -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__ diff --git a/SL/DB/Inventory.pm b/SL/DB/Inventory.pm index 3dccdd5f2..8557719d5 100644 --- a/SL/DB/Inventory.pm +++ b/SL/DB/Inventory.pm @@ -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, -- 2.20.1