Fix #15143 selected lines on invoice creation

This commit is contained in:
Maxime Kohlhaas 2020-10-25 09:28:41 +01:00
parent cf4ea4168d
commit 309691f1e7

View File

@ -997,6 +997,7 @@ if (empty($reshook))
elseif ($action == 'add' && $usercancreate)
{
if ($socid > 0) $object->socid = GETPOST('socid', 'int');
$selectedLines = GETPOST('toselect', 'array');
$db->begin();
@ -1586,8 +1587,11 @@ if (empty($reshook))
$fk_parent_line = 0;
$num = count($lines);
for ($i = 0; $i < $num; $i++)
{
if (!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines
// Don't add lines with qty 0 when coming from a shipment including all order lines
if ($srcobject->element == 'shipping' && $conf->global->SHIPMENT_GETS_ALL_ORDER_PRODUCTS && $lines[$i]->qty == 0) continue;
// Don't add closed lines when coming from a contract (Set constant to '0,5' to exclude also inactive lines)
@ -3647,8 +3651,6 @@ if ($action == 'create')
print '<input type="button" class="button" value="'.$langs->trans("Cancel").'" onClick="javascript:history.go(-1)">';
print '</div>';
print "</form>\n";
// Show origin lines
if (!empty($origin) && !empty($originid) && is_object($objectsrc)) {
print '<br>';
@ -3658,12 +3660,12 @@ if ($action == 'create')
print '<table class="noborder centpercent">';
$objectsrc->printOriginLinesList();
$objectsrc->printOriginLinesList('', $selectedLines);
print '</table>';
}
print '<br>';
print "</form>\n";
}
elseif ($id > 0 || !empty($ref))
{