Projektzwang bei Verkaufsaufträgen - auch Kunden verlinken
authorG. Richardson <information@kivitendo-premium.de>
Sun, 29 Nov 2015 21:46:41 +0000 (22:46 +0100)
committerJan Büren <jan@kivitendo-premium.de>
Mon, 30 Nov 2015 09:34:37 +0000 (10:34 +0100)
SL/OE.pm

index 5b7c16d..16ce8c1 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -537,9 +537,13 @@ sub save {
 
       # force new project, if not set yet
       if ($::instance_conf->get_order_always_project && !$form->{"globalproject_id"} && ($form->{type} eq 'sales_order')) {
+        require SL::DB::Customer;
+        my $customer = SL::DB::Manager::Customer->find_by( id => $form->{customer_id} );
+        die "Can't find customer" unless $customer;
         my $new_project = SL::DB::Project->new(
           projectnumber     => $form->{ordnumber},
-          description       => $form->{customer},
+          description       => $customer->name,
+          customer_id       => $customer->id,
           active            => 1,
           project_type_id   => $::instance_conf->get_project_type_id,
           project_status_id => $::instance_conf->get_project_status_id,