Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d2fdb900

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID d2fdb9005abf85d26ae12cf0d907f919acd0c170
  • Vorgänger 49d57e80
  • Nachfolger 4cf713a1

Model::Record: update_for_save_as_new implementiert

Unterschiede anzeigen:

SL/Controller/DeliveryOrder.pm
13 13
use SL::Webdav;
14 14
use SL::File;
15 15
use SL::MIME;
16
use SL::Util qw(trim);
17 16
use SL::YAML;
18 17
use SL::DB::History;
19 18
use SL::DB::Order;
......
240 239
    return $self->js->render();
241 240
  }
242 241

  
243
  # load order from db to check if values changed
244 242
  my $saved_order = SL::DB::DeliveryOrder->new(id => $order->id)->load;
245 243

  
246
  my %new_attrs;
247
  # Lets assign a new number if the user hasn't changed the previous one.
248
  # If it has been changed manually then use it as-is.
249
  $new_attrs{number}    = (trim($order->number) eq $saved_order->number)
250
                        ? ''
251
                        : trim($order->number);
252

  
253
  # Clear transdate unless changed
254
  $new_attrs{transdate} = ($order->transdate == $saved_order->transdate)
255
                        ? DateTime->today_local
256
                        : $order->transdate;
257

  
258
  # Set new reqdate unless changed if it is enabled in client config
259
  $new_attrs{reqdate} = $self->type_data->get_reqdate_by_type($order->reqdate, $saved_order->reqdate);
260

  
261
  # Update employee
262
  $new_attrs{employee}  = SL::DB::Manager::Employee->current;
263

  
264 244
  # Create new record from current one
265
  $self->order(SL::DB::DeliveryOrder->new_from($order, destination_type => $order->type, attributes => \%new_attrs));
245
  my $updated_order = SL::Model::Record->update_for_save_as_new($saved_order, $order);
246

  
247
  $self->order($updated_order);
266 248

  
267 249
  # no linked records on save as new
268 250
  delete $::form->{$_} for qw(converted_from_oe_id converted_from_orderitems_ids);

Auch abrufbar als: Unified diff