How to perform calculation like sum and average on all or filtered rows of particular field of doctype in python script?