Skip to content

Commit

Permalink
[MIG] mail_notification_custom_subject: Migration to 15.0
Browse files Browse the repository at this point in the history
TT36470
  • Loading branch information
victoralmau committed Oct 19, 2022
1 parent 405f4ef commit e3d5033
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 80 deletions.
10 changes: 5 additions & 5 deletions mail_notification_custom_subject/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Mail Notification Custom Subject
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github
:target: https://github.com/OCA/social/tree/14.0/mail_notification_custom_subject
:target: https://github.com/OCA/social/tree/15.0/mail_notification_custom_subject
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-14-0/social-14-0-mail_notification_custom_subject
:target: https://translation.odoo-community.org/projects/social-15-0/social-15-0-mail_notification_custom_subject
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/205/14.0
:target: https://runbot.odoo-community.org/runbot/205/15.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -60,7 +60,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/social/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_notification_custom_subject%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mail_notification_custom_subject%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -105,6 +105,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-joao-p-marques|

This module is part of the `OCA/social <https://github.com/OCA/social/tree/14.0/mail_notification_custom_subject>`_ project on GitHub.
This module is part of the `OCA/social <https://github.com/OCA/social/tree/15.0/mail_notification_custom_subject>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion mail_notification_custom_subject/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Mail Notification Custom Subject",
"summary": "Apply a custom subject to mail notifications",
"version": "14.0.1.0.0",
"version": "15.0.1.0.0",
"category": "Social Network",
"website": "https://github.com/OCA/social",
"author": "Tecnativa, Odoo Community Association (OCA)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class MailMessageCustomSubject(models.Model):
required=True,
)
subject_template = fields.Char(
string="Subject Template",
required=True,
help="Subject (placeholders may be used here)",
)
Expand All @@ -32,7 +31,6 @@ class MailMessageCustomSubject(models.Model):
("append_after", "Append After"),
("replace", "Replace"),
],
string="Position",
default="replace",
help="Whether to replace, append at beggining or append at end to other"
" templates that apply to a given context",
Expand Down
4 changes: 1 addition & 3 deletions mail_notification_custom_subject/models/mail_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ def message_post(
subtype_xmlid=None,
subtype_id=False,
partner_ids=None,
channel_ids=None,
attachments=None,
attachment_ids=None,
add_sign=True,
record_name=False,
**kwargs
):
if not subtype_id and subtype_xmlid:
subtype_id = self.env["ir.model.data"].xmlid_to_res_id(
subtype_id = self.env["ir.model.data"]._xmlid_to_res_id(
subtype_xmlid,
raise_if_not_found=False,
)
Expand Down Expand Up @@ -71,7 +70,6 @@ def message_post(
subtype_xmlid=subtype_xmlid,
subtype_id=subtype_id,
partner_ids=partner_ids,
channel_ids=channel_ids,
attachments=attachments,
attachment_ids=attachment_ids,
add_sign=add_sign,
Expand Down
1 change: 1 addition & 0 deletions mail_notification_custom_subject/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Pedro M. Baeza
* João Marques
* Carlos Roca
* Víctor Martínez

* Versada <https://versada.eu>
* Naglis Jonaitis
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>Mail Notification Custom Subject</title>
<style type="text/css">

Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Mail Notification Custom Subject</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/social/tree/14.0/mail_notification_custom_subject"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/social-14-0/social-14-0-mail_notification_custom_subject"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/205/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/social/tree/15.0/mail_notification_custom_subject"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/social-15-0/social-15-0-mail_notification_custom_subject"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/205/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows you to specify templates to override the subject on the notification
emails sent by Odoo</p>
<p><strong>Table of contents</strong></p>
Expand Down Expand Up @@ -416,7 +416,7 @@ <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/social/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_notification_custom_subject%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mail_notification_custom_subject%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -458,7 +458,7 @@ <h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/joao-p-marques"><img alt="joao-p-marques" src="https://github.com/joao-p-marques.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/14.0/mail_notification_custom_subject">OCA/social</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/15.0/mail_notification_custom_subject">OCA/social</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Copyright 2020 Tecnativa - João Marques
# Copyright 2022 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# pylint: disable=C8107
from odoo.tests import common
from odoo.tools import mute_logger


class TestMailNotificationCustomSubject(common.SavepointCase):
class TestMailNotificationCustomSubject(common.TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand All @@ -26,7 +27,7 @@ def test_email_subject_template_overrides(self):
"name": "Test template 1",
"model_id": self.env.ref("base.model_res_partner").id,
"subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])],
"subject_template": "${object.name or 'n/a'} and something more",
"subject_template": "{{object.name or 'n/a'}} and something more",
}
)
# Send message in partner
Expand Down Expand Up @@ -56,7 +57,7 @@ def test_email_subject_template_normal(self):
"name": "Test template 1",
"model_id": self.env.ref("base.model_res_partner").id,
"subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])],
"subject_template": "${object.name or 'n/a'} and something more",
"subject_template": "{{object.name or 'n/a'}} and something more",
}
)
# Send note in partner
Expand All @@ -72,15 +73,15 @@ def test_email_subject_template_multi(self):
"name": "Test template 1",
"model_id": self.env.ref("base.model_res_partner").id,
"subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])],
"subject_template": "${object.name or 'n/a'} and something more",
"subject_template": "{{object.name or 'n/a'}} and something more",
}
)
self.env["mail.message.custom.subject"].create(
{
"name": "Test template 2",
"model_id": self.env.ref("base.model_res_partner").id,
"subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])],
"subject_template": "${object.name or 'n/a'} and something different",
"subject_template": "{{object.name or 'n/a'}} and something different",
}
)
# Send message in partner
Expand All @@ -96,7 +97,7 @@ def test_email_subject_template_multi(self):
"name": "Test template 3",
"model_id": self.env.ref("base.model_res_partner").id,
"subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])],
"subject_template": "${' and yet something else'}",
"subject_template": "{{' and yet something else'}}",
"position": "append_after",
}
)
Expand All @@ -114,7 +115,7 @@ def test_email_subject_template_multi(self):
"name": "Test template 4",
"model_id": self.env.ref("base.model_res_partner").id,
"subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])],
"subject_template": "${'Re: '}",
"subject_template": "{{'Re: '}}",
"position": "append_before",
}
)
Expand All @@ -134,7 +135,7 @@ def test_email_subject_template_w_original(self):
"name": "Test template 1",
"model_id": self.env.ref("base.model_res_partner").id,
"subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])],
"subject_template": "${' and something more'}",
"subject_template": "{{' and something more'}}",
"position": "append_after",
}
)
Expand All @@ -154,7 +155,7 @@ def test_bad_template_does_not_break(self):
"name": "Test bad template 1",
"model_id": self.env.ref("base.model_res_partner").id,
"subtype_ids": [(6, 0, [self.env.ref("mail.mt_comment").id])],
"subject_template": "${obaject.number_a} and something",
"subject_template": "{{obaject.number_a}} and something",
"position": "append_after",
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,59 +1,53 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<data>
<record model="ir.ui.view" id="mail_notification_custom_subject_form">
<field name="name">mail.message.custom.subject.form</field>
<field name="model">mail.message.custom.subject</field>
<field name="arch" type="xml">
<form string="Subject Replacement Templates">
<sheet>
<div class="oe_title">
<label for="name" class="oe_edit_only" />
<h1 name="name"><field name="name" /></h1>
</div>
<group>
<field
name="subject_template"
placeholder="Subject (placeholders may be used here)"
/>
<field name="model_id" options="{'no_create': True}" />
<field name="subtype_ids" widget="many2many_tags" />
<field name="position" />
</group>
</sheet>
</form>
</field>
</record>

<record model="ir.ui.view" id="mail_notification_custom_subject_tree">
<field name="name">mail.message.custom.subject.tree</field>
<field name="model">mail.message.custom.subject</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="model_id" />
<field name="subtype_ids" />
<field name="subject_template" />
</tree>
</field>
</record>

<record
model="ir.actions.act_window"
id="action_mail_notification_custom_subject_tree_all"
>
<field name="name">Subject Replacement Templates</field>
<field name="res_model">mail.message.custom.subject</field>
<field name="view_mode">form,tree</field>
<field name="view_id" ref="mail_notification_custom_subject_tree" />
</record>

<menuitem
id="menu_mail_notification_custom_subject"
parent="base.menu_email"
action="action_mail_notification_custom_subject_tree_all"
sequence="21"
/>

</data>
<record model="ir.ui.view" id="mail_notification_custom_subject_form">
<field name="name">mail.message.custom.subject.form</field>
<field name="model">mail.message.custom.subject</field>
<field name="arch" type="xml">
<form string="Subject Replacement Templates">
<sheet>
<div class="oe_title">
<label for="name" class="oe_edit_only" />
<h1 name="name"><field name="name" /></h1>
</div>
<group>
<field
name="subject_template"
placeholder="Subject (placeholders may be used here)"
/>
<field name="model_id" options="{'no_create': True}" />
<field name="subtype_ids" widget="many2many_tags" />
<field name="position" />
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.ui.view" id="mail_notification_custom_subject_tree">
<field name="name">mail.message.custom.subject.tree</field>
<field name="model">mail.message.custom.subject</field>
<field name="arch" type="xml">
<tree>
<field name="name" />
<field name="model_id" />
<field name="subtype_ids" />
<field name="subject_template" />
</tree>
</field>
</record>
<record
model="ir.actions.act_window"
id="action_mail_notification_custom_subject_tree_all"
>
<field name="name">Subject Replacement Templates</field>
<field name="res_model">mail.message.custom.subject</field>
<field name="view_mode">form,tree</field>
<field name="view_id" ref="mail_notification_custom_subject_tree" />
</record>
<menuitem
id="menu_mail_notification_custom_subject"
parent="base.menu_email"
action="action_mail_notification_custom_subject_tree_all"
sequence="21"
/>
</odoo>

0 comments on commit e3d5033

Please sign in to comment.