]> wagnertech.de Git - kivitendo-erp.git/commitdiff
Auftrags-Controller: CVars: leere CVars bei neuen items anlegen und id merken
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 11 Sep 2015 12:05:01 +0000 (14:05 +0200)
committerG. Richardson <information@kivitendo-premium.de>
Mon, 16 Nov 2015 15:15:57 +0000 (16:15 +0100)
SL/Controller/Order.pm
templates/webpages/order/tabs/_row.html

index 79ff2934faba460328cd17cfa80955fd26d9afae..83938509f1f8b8a5995c6ac9cf88451eed84c686 100644 (file)
@@ -151,6 +151,11 @@ sub action_add_item {
   $new_attr{sellprice}   = $part->sellprice   if ! $item->sellprice;
   $new_attr{discount}    = $cv_discount       if ! $item->discount;
 
   $new_attr{sellprice}   = $part->sellprice   if ! $item->sellprice;
   $new_attr{discount}    = $cv_discount       if ! $item->discount;
 
+  # add_custom_variables adds cvars to an orderitem with no cvars for saving, but
+  # they cannot be retrieved via custom_variables until the order/orderitem is
+  # saved. Adding empty custom_variables to new orderitem here solves this problem.
+  $new_attr{custom_variables} = [];
+
   $item->assign_attributes(%new_attr);
 
   $self->order->add_items($item);
   $item->assign_attributes(%new_attr);
 
   $self->order->add_items($item);
index ca340ebf8f9f9415770dc4c94025e61a4560cd77..fc2776d1399a610d26572e5e2b8e7b81ae75f8e5 100644 (file)
@@ -74,6 +74,8 @@
             </th>
             <td>
               [% L.hidden_tag('order.orderitems[].custom_variables[+].config_id', var.config.id) %]
             </th>
             <td>
               [% L.hidden_tag('order.orderitems[].custom_variables[+].config_id', var.config.id) %]
+              [% L.hidden_tag('order.orderitems[].custom_variables[].id', var.id) %]
+              [% L.hidden_tag('order.orderitems[].custom_variables[].sub_module', var.sub_module) %]
               [% INCLUDE 'common/render_cvar_input.html' var_name='order.orderitems[].custom_variables[].unparsed_value' %]
             </td>
             [%- IF (n % (MYCONFIG.form_cvars_nr_cols || 3)) == 0 %]
               [% INCLUDE 'common/render_cvar_input.html' var_name='order.orderitems[].custom_variables[].unparsed_value' %]
             </td>
             [%- IF (n % (MYCONFIG.form_cvars_nr_cols || 3)) == 0 %]