I have an email template which is sent whenever a new record is created. This email is sent to only one person as I have specified only one email id in the email_to field.
I have also created a custom group for users only. I wanted to send an email notification to all the users of the users' group by checking if email id is present or not iteratively after the new record is created. How can I get email id of users from users' group in email_to field in email template and sent automatically?
in your mail template
<field name="email_to">${object.get_email_to()}</field>
python method like this
@api.model
def get_email_to(self):
user_group = self.env.ref("res.group_res_user")
email_list = [
usr.partner_id.email for usr in user_group.users if usr.partner_id.email]
return ",".join(email_list)
hope this is working well with your requirement..