I was not referring to costs to the customer. A credit note reflects a credit to the customer’s account, which you might then refund. If you are not adjusting the customer’s account in any way, but only absorbing the expense of repairing or replacing the device, then your expenses should be recorded as normal purchases, either with purchase invoices or payments, naming whoever you will pay the money to.
Such transactions can be posted to an expense account set up for the purpose. You cannot easily track the effect on profit margin for the inventory item, though, because you cannot post anything directly to the Inventory - cost account. And if you post the costs (at zero quantity) to Inventory on hand, that only affects the average cost of items remaining in stock, not the cost of items already sold.
In my experience, warranty costs are not attributed to individual items. Gross profit is calculated as inventory sales less cost of goods sold. Warranty and repair costs are tracked as a separate operating expense. If you want to calculate the effect on profitability of warranty expenses, you can make certain to describe them thoroughly. Then you’ll be able to search and export or generate custom reports based on what they pertain to. I can tell you, however, that kind of information is often easier to get from a customer support system than from your accounting program.