Custom Script for Frappe app

I am new to erpnext and frappe framework. I am creating a custom app for the creation of drawing numbering system for engineering drawing.

In this module I have created three Doctypes:

1. Drawings Codes: It stores component info (conductor, machined components, hardware etc) and its fields are major_code (storing two characters like CN for conductor), major_description, minor_codes (a child table field its doctype information mentioned below Refer number 2 below)
2. Minor Codes: A child doctype of above (i.e. Drawing Codes doctype) that store info like materials (e.g Copper, Brass, Plastic etc). It has the field minor_code (two character like CU for conductor, BR for brass), minor_description.
3 Dwg Numbers : It is a doctype that user will use to create drawing numbers. It fields are major_description (link field to Drawing Codes for selecting Major Codes), major_code, minor_description, minor_code, product line, project and description.

What is required.

  1. Once major description is selected. Its corresponding minor description shall be available to users for selection from child table and after selecting minor description auto filling of the minor_code.
  2. AUTO NUMBERING of document based on combination of major_code + minor_code + seven digit running serial number for each combination. i.e if user select conductor + copper combination the document name should be CNCU-0000001.

Please refer the attachment for detail