Auftrags-Controller: item->id per Hand setzten (assign_attributes lässt Primärschlüss...
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 2 Sep 2015 12:46:36 +0000 (14:46 +0200)
committerG. Richardson <information@kivitendo-premium.de>
Mon, 16 Nov 2015 15:15:57 +0000 (16:15 +0100)
SL/Controller/Order.pm

index c532740..b6cdef4 100644 (file)
@@ -143,14 +143,15 @@ sub action_add_item {
   my $cv_discount = $self->order->customer? $self->order->customer->discount : 0.0;
 
   my %new_attr;
-  $new_attr{id}          = join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000);
   $new_attr{part}        = $part;
   $new_attr{description} = $part->description if ! $item->{description};
   $new_attr{qty}         = 1.0                if ! $item->{qty};
   $new_attr{unit}        = $part->unit;
   $new_attr{sellprice}   = $part->sellprice   if ! $item->{sellprice};
   $new_attr{discount}    = $cv_discount       if ! $item->{discount};
+
   $item->assign_attributes(%new_attr);
+  $item->id(join('_', 'new', Time::HiRes::gettimeofday(), int rand 1000000000000)) if !$item->id;
 
   $self->order->add_items($item);