diff --git a/mail_notification_custom_subject/models/mail_message_custom_subject.py b/mail_notification_custom_subject/models/mail_message_custom_subject.py index 5aaeecc..19a48f6 100644 --- a/mail_notification_custom_subject/models/mail_message_custom_subject.py +++ b/mail_notification_custom_subject/models/mail_message_custom_subject.py @@ -16,7 +16,9 @@ class MailMessageCustomSubject(models.Model): help="Model where this template applies", ) subtype_ids = fields.Many2many( - comodel_name="mail.message.subtype", string="Applied Subtypes", required=True, + comodel_name="mail.message.subtype", + string="Applied Subtypes", + required=True, ) subject_template = fields.Char( string="Subject Template", diff --git a/mail_notification_custom_subject/models/mail_thread.py b/mail_notification_custom_subject/models/mail_thread.py index 8743fcb..96d9abe 100644 --- a/mail_notification_custom_subject/models/mail_thread.py +++ b/mail_notification_custom_subject/models/mail_thread.py @@ -29,16 +29,23 @@ class MailThread(models.AbstractModel): if "." not in subtype: subtype = "mail.%s" % subtype subtype_id = self.env["ir.model.data"].xmlid_to_res_id( - subtype, raise_if_not_found=False, + subtype, + raise_if_not_found=False, ) if subtype_id: custom_subjects = self.env["mail.message.custom.subject"].search( [("model_id.model", "=", self._name), ("subtype_ids", "=", subtype_id)] ) if not subject: - subject = "Re: %s" % self.env["mail.message"].with_context( - default_model=self._name, default_res_id=self.id, - )._get_record_name({}) + subject = ( + "Re: %s" + % self.env["mail.message"] + .with_context( + default_model=self._name, + default_res_id=self.id, + ) + ._get_record_name({}) + ) for template in custom_subjects: try: rendered_subject_template = self.env[ diff --git a/mail_notification_custom_subject/tests/test_mail_notification_custom_subject.py b/mail_notification_custom_subject/tests/test_mail_notification_custom_subject.py index 26222b0..68cbc7f 100644 --- a/mail_notification_custom_subject/tests/test_mail_notification_custom_subject.py +++ b/mail_notification_custom_subject/tests/test_mail_notification_custom_subject.py @@ -134,7 +134,9 @@ class TestMailNotificationCustomSubject(common.TransactionCase): ) # Send message in partner mail_message_1 = self.partner_1.message_post( - body="Test", subtype="mail.mt_comment", subject="Test", + body="Test", + subtype="mail.mt_comment", + subject="Test", ) # Get message and check subject self.assertEquals(mail_message_1.subject, "Test and something more") @@ -152,7 +154,9 @@ class TestMailNotificationCustomSubject(common.TransactionCase): ) # Send message in partner mail_message_1 = self.partner_1.message_post( - body="Test", subtype="mail.mt_comment", subject="Test", + body="Test", + subtype="mail.mt_comment", + subject="Test", ) # Get message and check subject # No exception should be raised but subject should remain as original.