I'm writing custom module based on Odoo 9.
When state change from draft to confirm, I need to create CSV files contain let say his ordered and email it automatically to person who's ordered (res.partner).
I don't know how to start write code for creating CSV and Email it automatically. Any suggestion article or example or modules?
Thanks.