Work on BOM

This commit is contained in:
Laurent Destailleur 2019-11-11 20:56:28 +01:00
parent 4f7b698e92
commit 79cc3f189d
3 changed files with 44 additions and 22 deletions

View File

@ -634,6 +634,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=reopen">' . $langs->trans("ReOpen") . '</a>'; print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=reopen">' . $langs->trans("ReOpen") . '</a>';
} }
// Create MO
if ($object->status == $object::STATUS_VALIDATED && ! empty($user->rights->mrp->write))
{
print '<a class="butAction" href="' . DOL_URL_ROOT.'/mrp/mo_card.php?action=create&fk_bom='.$object->id.'">' . $langs->trans("CreateMO") . '</a>';
}
// Clone // Clone
if ($permissiontoadd) if ($permissiontoadd)
{ {

View File

@ -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 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 BomAndBomLines=Bills Of Material and lines
BOMLine=Line of BOM BOMLine=Line of BOM
WarehouseForProduction=Warehouse for production WarehouseForProduction=Warehouse for production
CreateMO=Create MO

View File

@ -209,31 +209,46 @@ if ($action == 'create')
$(document).ready(function () { $(document).ready(function () {
jQuery('#fk_bom').change(function() { jQuery('#fk_bom').change(function() {
console.log('We change value of BOM with BOM of id '+jQuery('#fk_bom').val()); console.log('We change value of BOM with BOM of id '+jQuery('#fk_bom').val());
if (jQuery('#fk_bom').val() > 0)
$.getJSON('<?php echo DOL_URL_ROOT ?>/mrp/ajax/ajax_bom.php?action=getBoms&idbom='+jQuery('#fk_bom').val(), function(data) { {
console.log(data); $.getJSON('<?php echo DOL_URL_ROOT ?>/mrp/ajax/ajax_bom.php?action=getBoms&idbom='+jQuery('#fk_bom').val(), function(data) {
if (typeof data.rowid != "undefined") { console.log(data);
console.log("New BOM loaded, we set values in form"); if (typeof data.rowid != "undefined") {
$('#qty').val(data.qty); console.log("New BOM loaded, we set values in form");
$("#fk_product").val(data.fk_product); $('#qty').val(data.qty);
$('#fk_product').trigger('change'); // Notify any JS components that the value changed $("#fk_product").val(data.fk_product);
$('#note_private').val(data.description); $('#fk_product').trigger('change'); // Notify any JS components that the value changed
$('#note_private').trigger('change'); // Notify any JS components that the value changed $('#note_private').val(data.description);
$('#fk_warehouse').val(data.fk_warehouse); $('#note_private').trigger('change'); // Notify any JS components that the value changed
$('#fk_warehouse').trigger('change'); // Notify any JS components that the value changed $('#fk_warehouse').val(data.fk_warehouse);
if (typeof CKEDITOR != "undefined") { $('#fk_warehouse').trigger('change'); // Notify any JS components that the value changed
if (typeof CKEDITOR.instances != "undefined") { if (typeof CKEDITOR != "undefined") {
if (typeof CKEDITOR.instances.note_private != "undefined") { if (typeof CKEDITOR.instances != "undefined") {
console.log(CKEDITOR.instances.note_private); if (typeof CKEDITOR.instances.note_private != "undefined") {
CKEDITOR.instances.note_private.setData(data.description); 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');
}) })
</script> </script>
<?php <?php