SL::DB::DeliveryOrder: donumber in before_save-Hook erzeugen
authorMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 11 Jul 2013 07:28:38 +0000 (09:28 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 11 Jul 2013 07:30:01 +0000 (09:30 +0200)
SL/DB/DeliveryOrder.pm

index 7b530c6..372a5cc 100644 (file)
@@ -20,6 +20,18 @@ __PACKAGE__->meta->add_relationship(orderitems => { type         => 'one to many
 
 __PACKAGE__->meta->initialize;
 
+__PACKAGE__->before_save('_before_save_set_donumber');
+
+# hooks
+
+sub _before_save_set_donumber {
+  my ($self) = @_;
+
+  $self->create_trans_number if !$self->donumber;
+
+  return 1;
+}
+
 # methods
 
 sub items { goto &orderitems; }