FIX Duplicate select2 when we split a supplier order receipt item

This commit is contained in:
Laurent Destailleur
2018-06-16 17:18:17 +02:00
parent 5524784421
commit 7ad086bbdf
3 changed files with 14 additions and 10 deletions

View File

@@ -32,10 +32,10 @@ function addDispatchLine(index, type, mode)
{
mode = mode || 'qtymissing'
console.log("Split line type="+type+" index="+index+" mode="+mode);
var $row = $("tr[name='"+type+'_0_'+index+"']").clone(true), // clone first batch line to jQuery object
console.log("fourn/js/lib_dispatch.js Split line type="+type+" index="+index+" mode="+mode);
var $row = $("tr[name='"+type+'_0_'+index+"']").clone(true), // clone first batch line to jQuery object
nbrTrs = $("tr[name^='"+type+"_'][name$='_"+index+"']").length, // position of line for batch
qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()), // Qty ordered is same for all rows
qtyOrdered = parseFloat($("#qty_ordered_0_"+index).val()), // Qty ordered is same for all rows
qty = parseFloat($("#qty_"+(nbrTrs - 1)+"_"+index).val()),
qtyDispatched;
@@ -62,8 +62,11 @@ function addDispatchLine(index, type, mode)
$row.attr('name',type+'_'+nbrTrs+'_'+index);
//insert new row before last row
$("tr[name^='"+type+"_'][name$='_"+index+"']:last").after($row);
//remove cloned select2 with duplicate id.
$("#s2id_entrepot_"+nbrTrs+'_'+index).detach();
$("#s2id_entrepot_"+nbrTrs+'_'+index).detach(); // old way to find duplicated select2 component
$(".csswarehouse_"+nbrTrs+"_"+index+":first-child").parents("span.selection").parents(".select2").detach();
/* Suffix of lines are: _ trs.length _ index */
$("#qty_"+nbrTrs+"_"+index).focus();
$("#qty_dispatched_0_"+index).val(qtyDispatched);