Add a TOTAL row in child table


What is the best method to add a row to the child table of a DocType (Sales Order for example) that shows the sum of a certain column or columns (the amount for example) in PRINT.

In other words, if we add two items to a Sales order, a third row will be created that displays the sum of the amounts of the two items in the table that appears in the Print document (and pdf).