The script must be pasted on the corresponding document at:

Settings->Purchase/sales->Documents->Run SQL

To automatically create a consignment document that includes the combined products of the receipt issued, paste the following script to the corresponding documents(Up to 2 levels, combined product and combined product combination)

For automatic release of document number 7:

For purchase with automatic issue of document number 52: