I am trying to write code to raise a warning when a user forgets to enter phone number or email in the contact linked to a sales order. This is what I have so far and it works:
Model: sale.order
if not record.partner_id.phone and not record.partner_id.mobile:
raise Warning('Customer phone number is not set')
if not record.partner_id.email:
raise Warning('Customer email is not set')
if not record.partner_shipping_id.phone and not record.partner_shipping_id.mobile:
raise Warning('Shipping Address phone number is not set')
if not record.partner_shipping_id.email:
raise Warning('Shipping Address email is not set')
if len(record.partner_shipping_id.name) > 35:
raise Warning('Delivery Address: Name field is greater than 35 characters')
if len(record.partner_shipping_id.street) > 35:
raise Warning('Delivery Address: Street 1 field is greater than 35 characters')
My question is how can I raise one Warning with all the missing fields? Basically Make my warning text to be dynamic and print a list of the Display Name of all the missing fields.