Warning Message based on a condition

How to show warning message in the sales invoice , if the trade license of the customer got expired?

frappe.publish_realtime(event='msgprint',message='hello',user='user@example.com')

Use this for message!

@Shah_Kalpit Thanks for your reply. Can i write this code in the custom script. Also I want to give the condition for sales invoice that Trade License Expiry should validate the current date . Please advise