How to perform operation in form for new custom doctype?

I create a new doctype with the name Sale Stock Report. Now, I need some code customization according to my requirement. I have a child doctype in it with the name SSR Product Detail.
Requirements:

  1. When I select the product in child doctype, it will auto get the price of that product which I was selected.
  2. When I enter the value of opening_stock and purchase it will aslo auto calculate the addition of both field in the next field total.

Continuing the discussion from How to perform operation in form for new custom doctype?:

http://0.0.0.0:8000/desk#Form/Sale%20Stock%20Report/New%20Sale%20Stock%20Report%201![Capture|690x209](upload://72o3inzZKXZbRFZUQzCJFGVKCnv.jpeg)

This is the view of doctype when i select the product it should auto show that price into the next fields. When I enter the values of opening_stock and purchase it will auto sum that value into the next field total.