Step 1: Create catalog_product_new.xml file under your_module/view/adminhtml/layout
Below is content of catalog_product_new.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="js">
<block class="Magento\Framework\View\Element\Template" name="js.seller_stock_disabler" template="Rootways_CatalogInventory::product/stock/disabler.phtml"/>
</referenceContainer>
</body>
</page>
Step 2: Create disabler.phtml file under your_module/view/adminthml/templates/product/stock
Below is content of disabler.phtml
<script>
require(['jquery'], function($) {
window.afterOptionsInit = function() {
if (!jQuery('[data-index = quantity_and_stock_status_qty] input')[0]) {
setTimeout(function(){window.afterOptionsInit();}, 500);
return;
}
$( "[data-index = quantity_and_stock_status_qty] input" ).attr("disabled", "true");
$( "[data-index = quantity_and_stock_status_qty] .admin__field-group-additional" ).hide();
}
window.afterOptionsInit();
});
</script>