From f608bce9b80a9acf7b6ff76e099f29c69bc1056b Mon Sep 17 00:00:00 2001 From: miad-odoo Date: Wed, 27 Sep 2023 16:50:45 +0200 Subject: [PATCH] [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 --- addons/mail/wizard/mail_compose_message.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 0bf09d68f59..f5d4272833d 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -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,