How to create and submit a purchase receipt when a purchase order is submitted auto

How to create and submit a purchase receipt when a purchase order is submitted automatically.

Reference:

When submitting the Sales Order then automatically submit the Delivery Note so you have to same logic apply for purchase.

example any

Already provided the reference and code.

thanks