If you create a Credit Memo in Magento the default quantities to refund are equal to the amount which was initially ordered. If you have a large number of items which have been ordered and you only want to refund one of them it is very tiring to set all the quantities to 0. Especially if you are processing a lot of orders per day. Below is a small unobtrusive Javascript snippet (based on Prototype) which adds a "Set Qty´s to 0" button on the credit memo form. Simple upload the .js file (e.g. in folder youddomain/js/someDir/) and add it to the sales.xml file of your theme.
document.observe("dom:loaded", function() {
if($$('#creditmemo_item_container .data.order-tables .update-button')[0]){
YourName.init();
};
});
var YourName = {
init : function(){
var my_div = document.createElement('div');
Element.extend(my_div);
my_div.addClassName('form-button');
my_div.setStyle({
display:'inline-block',
marginLeft: '3px'
});
my_div.innerHTML ='Set Qtys to 0';
my_div.observe('click', YourName.refresh);
$$('#creditmemo_item_container .data.order-tables .update-button')[0].insert({after:my_div});
},
refresh : function(){
$$('input.input-text.qty-input').each(function(item) {
item.value='0';
});
$('shipping_amount').value='0';
$$('#creditmemo_item_container .data.order-tables .update-button').each(function (elem) {elem.disabled=false;elem.removeClassName('disabled');});
$$('#creditmemo_item_container .data.order-tables .update-button')[0].click();
}
};
<adminhtml_sales_order_creditmemo_new>
<reference name="head">
<action method="addJs"><script>someDir/cm.js</script></action>
</reference>