[IMP] mail: prevent saving template when no model

With this commit, we now raise a UserError if a user tries to save a template
with a composer that has no attached model.

Task-2504439

Part-of: odoo/odoo#126049
This commit is contained in:
miad-odoo
2023-09-29 13:11:50 +00:00
parent 39dd2fc2ab
commit f608bce9b8
+3 -1
View File
@@ -722,8 +722,10 @@ class MailComposer(models.TransientModel):
}
def create_mail_template(self):
""" creates a mail template with the information form the current mail composer """
""" creates a mail template with the current mail composer's fields """
self.ensure_one()
if not self.model or not self.model in self.env:
raise UserError(_('Template creation from composer requires a valid model.'))
model_id = self.env['ir.model']._get_id(self.model)
values = {
'name': self.subject,