From 86445cdd83deca5ca37feed3bf316273f0b873e3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Apr 2023 01:08:23 +0200 Subject: [PATCH] NEW Dynamic choice of warehouse and batch in MO production. --- htdocs/mrp/mo_production.php | 29 +++++++++++++------ .../product/class/html.formproduct.class.php | 2 ++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 3b538a06902..8d3d11d167d 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -672,7 +672,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print '
'.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'
'; - print ''.$langs->trans("InventoryCode").':   '; + print ''.$langs->trans("InventoryCode").':   '; print ''; print $langs->trans("MovementLabel").':

'; print '
'; @@ -1080,7 +1080,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; if ($tmpproduct->status_batch) { $preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : ''); - print ''; + print ''; print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, '', ''); } print ''; @@ -1458,7 +1458,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; if ($tmpproduct->status_batch) { $preselected = (GETPOSTISSET('batchtoproduce-'.$line->id.'-'.$i) ? GETPOST('batchtoproduce-'.$line->id.'-'.$i) : ''); - print ''; + print ''; } print ''; // Batch number in same column than the stock movement picto @@ -1510,9 +1510,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea }); function updateselectbatchbywarehouse() { - var element = $("select[name*='idwarehouse']"); - - element.change(function () { + $(document).on('change', "select[name*='idwarehouse']", function () { + console.log("We change warehouse so we update the list of possible batch number"); var selectwarehouse = $(this); @@ -1529,13 +1528,19 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea action: "updateselectbatchbywarehouse", permissiontoproduce: , warehouse_id: $(this).val(), + token: '', product_id: $("input[name='" + product_element_name + "']").val() } }).done(function (data) { selectbatch.empty(); - var data = JSON.parse(data); + if (typeof data == "object") { + console.log("data is already type object, no need to parse it"); + } else { + console.log("data is type "+(typeof data)); + data = JSON.parse(data); + } selectbatch.append($('