]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Controller/RequirementSpecOrder.pm
restart apache2 in postinst
[mfinanz.git] / SL / Controller / RequirementSpecOrder.pm
index 398c86a47ed23faeb0279526a73cbc6763eee2a8..60f9b43ebc10950da15a8ce0196e1f6726220048 100644 (file)
@@ -10,6 +10,7 @@ use List::Util qw(first);
 
 use SL::DB::Customer;
 use SL::DB::Order;
+use SL::DB::Order::TypeData qw(:types);
 use SL::DB::Part;
 use SL::DB::RequirementSpec;
 use SL::DB::RequirementSpecOrder;
@@ -93,7 +94,7 @@ sub action_update {
   my $order    = $self->rs_order->order;
   my $sections = $self->requirement_spec->sections_sorted;
 
-  if (!$::auth->assert($order->quotation ? 'sales_quotation_edit' : 'sales_order_edit', 1)) {
+  if (!$::auth->assert($order->type_data->rights('edit'), 1)) {
     return $self->js->flash('error', t8("You do not have the permissions to access this function."))->render;
   }
 
@@ -368,11 +369,12 @@ sub create_order {
   my $reqdate    = !$::form->{quotation} ? undef
                  : $customer->payment_id ? $customer->payment->calc_date
                  :                         DateTime->today_local->next_workday(extra_days => $::instance_conf->get_reqdate_interval)->to_kivitendo;
+  my $record_type = $::form->{quotation} ? SALES_QUOTATION_TYPE() : SALES_ORDER_TYPE();
   my $order      = SL::DB::Order->new(
+    record_type             => $record_type,
     globalproject_id        => $self->requirement_spec->project_id,
     transdate               => DateTime->today_local,
     reqdate                 => $reqdate,
-    quotation               => !!$::form->{quotation},
     orderitems              => [ @orderitems, @add_items ],
     customer_id             => $customer->id,
     taxincluded             => $customer->taxincluded,