How to modify the quantities of a delivery and its movements of stock through code or import / export template

I have a validated delivery to which I want to modify both the delivery quantities and the quantities of the stock movements made; I need to do it by code or template.

Would anyone know what template to use or how could I develop it?