From 79cc3f189d226e5ba93bf92880ccc35aa98b97ce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Nov 2019 20:56:28 +0100 Subject: [PATCH] Work on BOM --- htdocs/bom/bom_card.php | 6 ++++ htdocs/langs/en_US/mrp.lang | 3 +- htdocs/mrp/mo_card.php | 57 +++++++++++++++++++++++-------------- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index bccc6755332..316d5e8e040 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -634,6 +634,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '' . $langs->trans("ReOpen") . ''; } + // Create MO + if ($object->status == $object::STATUS_VALIDATED && ! empty($user->rights->mrp->write)) + { + print '' . $langs->trans("CreateMO") . ''; + } + // Clone if ($permissiontoadd) { diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index fd89d8c8e38..c754d411408 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -48,4 +48,5 @@ DisableStockChange=Disable stock change DisableStockChangeHelp=When this flag is set, there is no stock change on this product, whatever is the quantity produced BomAndBomLines=Bills Of Material and lines BOMLine=Line of BOM -WarehouseForProduction=Warehouse for production \ No newline at end of file +WarehouseForProduction=Warehouse for production +CreateMO=Create MO \ No newline at end of file diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index e353612d9f4..3c003343a10 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -209,31 +209,46 @@ if ($action == 'create') $(document).ready(function () { jQuery('#fk_bom').change(function() { console.log('We change value of BOM with BOM of id '+jQuery('#fk_bom').val()); - - $.getJSON('/mrp/ajax/ajax_bom.php?action=getBoms&idbom='+jQuery('#fk_bom').val(), function(data) { - console.log(data); - if (typeof data.rowid != "undefined") { - console.log("New BOM loaded, we set values in form"); - $('#qty').val(data.qty); - $("#fk_product").val(data.fk_product); - $('#fk_product').trigger('change'); // Notify any JS components that the value changed - $('#note_private').val(data.description); - $('#note_private').trigger('change'); // Notify any JS components that the value changed - $('#fk_warehouse').val(data.fk_warehouse); - $('#fk_warehouse').trigger('change'); // Notify any JS components that the value changed - if (typeof CKEDITOR != "undefined") { - if (typeof CKEDITOR.instances != "undefined") { - if (typeof CKEDITOR.instances.note_private != "undefined") { - console.log(CKEDITOR.instances.note_private); - CKEDITOR.instances.note_private.setData(data.description); + if (jQuery('#fk_bom').val() > 0) + { + $.getJSON('/mrp/ajax/ajax_bom.php?action=getBoms&idbom='+jQuery('#fk_bom').val(), function(data) { + console.log(data); + if (typeof data.rowid != "undefined") { + console.log("New BOM loaded, we set values in form"); + $('#qty').val(data.qty); + $("#fk_product").val(data.fk_product); + $('#fk_product').trigger('change'); // Notify any JS components that the value changed + $('#note_private').val(data.description); + $('#note_private').trigger('change'); // Notify any JS components that the value changed + $('#fk_warehouse').val(data.fk_warehouse); + $('#fk_warehouse').trigger('change'); // Notify any JS components that the value changed + if (typeof CKEDITOR != "undefined") { + if (typeof CKEDITOR.instances != "undefined") { + if (typeof CKEDITOR.instances.note_private != "undefined") { + console.log(CKEDITOR.instances.note_private); + CKEDITOR.instances.note_private.setData(data.description); + } } } + } else { + console.log("Failed to get BOM"); } - } else { - console.log("Failed to get BOM"); - } - }); + }); + } + else { + /* + $('#qty').val(''); + $("#fk_product").val(''); + $('#fk_product').trigger('change'); // Notify any JS components that the value changed + $('#note_private').val(''); + $('#note_private').trigger('change'); // Notify any JS components that the value changed + $('#fk_warehouse').val(''); + $('#fk_warehouse').trigger('change'); // Notify any JS components that the value changed + */ + } }); + + jQuery('#fk_bom').trigger('change'); })