Skip to content

Commit 60985df

Browse files
dreisptdevin-ai-integration[bot]
authored andcommitted
[MIG] mail_autosubscribe: Migration to 19.0
Port mail_autosubscribe from 18.0 to 19.0. - Replace _sql_constraints with models.Constraint for Odoo 19.0 registry constraints. - Update _generate_template_recipients signature to accept and pass allow_suggested. - Update _message_get_default_recipients signature to accept and pass with_cc and all_tos. - Replace odoo_test_helper fake model loader with odoo.orm.model_classes.add_to_registry in tests. Assisted-by: Devin:SWE-1.7
1 parent 0301f8f commit 60985df

7 files changed

Lines changed: 32 additions & 31 deletions

File tree

mail_autosubscribe/README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Mail Autosubscribe
2121
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2222
:alt: License: AGPL-3
2323
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github
24-
:target: https://github.com/OCA/mail/tree/18.0/mail_autosubscribe
24+
:target: https://github.com/OCA/mail/tree/19.0/mail_autosubscribe
2525
:alt: OCA/mail
2626
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/mail-18-0/mail-18-0-mail_autosubscribe
27+
:target: https://translation.odoo-community.org/projects/mail-19-0/mail-19-0-mail_autosubscribe
2828
:alt: Translate me on Weblate
2929
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30-
:target: https://runboat.odoo-community.org/builds?repo=OCA/mail&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/mail&target_branch=19.0
3131
:alt: Try me on Runboat
3232

3333
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -70,7 +70,7 @@ Bug Tracker
7070
Bugs are tracked on `GitHub Issues <https://github.com/OCA/mail/issues>`_.
7171
In case of trouble, please check there if your issue has already been reported.
7272
If you spotted it first, help us to smash it by providing a detailed and welcomed
73-
`feedback <https://github.com/OCA/mail/issues/new?body=module:%20mail_autosubscribe%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
73+
`feedback <https://github.com/OCA/mail/issues/new?body=module:%20mail_autosubscribe%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
7474

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

@@ -106,6 +106,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
106106
mission is to support the collaborative development of Odoo features and
107107
promote its widespread use.
108108

109-
This module is part of the `OCA/mail <https://github.com/OCA/mail/tree/18.0/mail_autosubscribe>`_ project on GitHub.
109+
This module is part of the `OCA/mail <https://github.com/OCA/mail/tree/19.0/mail_autosubscribe>`_ project on GitHub.
110110

111111
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

mail_autosubscribe/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"name": "Mail Autosubscribe",
77
"summary": "Automatically subscribe partners to its company's business documents",
8-
"version": "18.0.1.1.0",
8+
"version": "19.0.1.0.0",
99
"author": "Camptocamp, Odoo Community Association (OCA)",
1010
"license": "AGPL-3",
1111
"category": "Marketing",

mail_autosubscribe/models/mail_autosubscribe.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@ class MailAutosubscribe(models.Model):
99
_name = "mail.autosubscribe"
1010
_description = "Mail Autosubscribe"
1111

12-
_sql_constraints = [
13-
(
14-
"model_id_unique",
15-
"UNIQUE(model_id)",
16-
"There's already a rule for this model",
17-
)
18-
]
12+
_model_id_unique = models.Constraint(
13+
"UNIQUE(model_id)",
14+
"There's already a rule for this model",
15+
)
1916

2017
model_id = fields.Many2one(
2118
"ir.model",

mail_autosubscribe/models/mail_template.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,19 @@ class MailTemplate(models.Model):
1111
use_autosubscribe_followers = fields.Boolean(default=True)
1212

1313
def _generate_template_recipients(
14-
self, res_ids, render_fields, find_or_create_partners=False, render_results=None
14+
self,
15+
res_ids,
16+
render_fields,
17+
allow_suggested=False,
18+
find_or_create_partners=False,
19+
render_results=None,
1520
):
1621
res = super()._generate_template_recipients(
17-
res_ids, render_fields, find_or_create_partners, render_results
22+
res_ids,
23+
render_fields,
24+
allow_suggested=allow_suggested,
25+
find_or_create_partners=find_or_create_partners,
26+
render_results=render_results,
1827
)
1928
autosubscribe_followers = (
2029
self.use_autosubscribe_followers

mail_autosubscribe/models/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ def _message_get_autosubscribe_followers(self, partners):
2121
domain = self._message_get_autosubscribe_followers_domain(partners)
2222
return self.env["res.partner"].sudo().search(domain)
2323

24-
def _message_get_default_recipients(self):
24+
def _message_get_default_recipients(self, with_cc=False, all_tos=False):
2525
# Overload to include auto follow document partners in the composer
2626
# Note: This only works if the template is configured with 'Default recipients'
27-
res = super()._message_get_default_recipients()
27+
res = super()._message_get_default_recipients(with_cc=with_cc, all_tos=all_tos)
2828
test_condition = config["test_enable"] and not self.env.context.get(
2929
"test_mail_autosubscribe"
3030
)

mail_autosubscribe/static/description/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>README.rst</title>
6+
<title>Mail Autosubscribe</title>
77
<style type="text/css">
88

99
/*
@@ -374,7 +374,7 @@ <h1>Mail Autosubscribe</h1>
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375375
!! source digest: sha256:eeb91ef9938aaa18e2ba8411d0415730aac67f2c5eed1ffc2328c6da011653b3
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/mail/tree/18.0/mail_autosubscribe"><img alt="OCA/mail" src="https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/mail-18-0/mail-18-0-mail_autosubscribe"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/mail&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/mail/tree/19.0/mail_autosubscribe"><img alt="OCA/mail" src="https://img.shields.io/badge/github-OCA%2Fmail-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/mail-19-0/mail-19-0-mail_autosubscribe"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/mail&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378378
<p>This module allows you to configure partners that will be automatically
379379
in copy of their company’s business documents.</p>
380380
<p>For example, you can configure an accountant to be in copy of all
@@ -417,7 +417,7 @@ <h2><a class="toc-backref" href="#toc-entry-3">Bug Tracker</a></h2>
417417
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/mail/issues">GitHub Issues</a>.
418418
In case of trouble, please check there if your issue has already been reported.
419419
If you spotted it first, help us to smash it by providing a detailed and welcomed
420-
<a class="reference external" href="https://github.com/OCA/mail/issues/new?body=module:%20mail_autosubscribe%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
420+
<a class="reference external" href="https://github.com/OCA/mail/issues/new?body=module:%20mail_autosubscribe%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
421421
<p>Do not contact contributors directly about support or help with technical issues.</p>
422422
</div>
423423
<div class="section" id="credits">
@@ -456,7 +456,7 @@ <h3><a class="toc-backref" href="#toc-entry-7">Maintainers</a></h3>
456456
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
457457
mission is to support the collaborative development of Odoo features and
458458
promote its widespread use.</p>
459-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/mail/tree/18.0/mail_autosubscribe">OCA/mail</a> project on GitHub.</p>
459+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/mail/tree/19.0/mail_autosubscribe">OCA/mail</a> project on GitHub.</p>
460460
<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>
461461
</div>
462462
</div>

mail_autosubscribe/tests/test_mail_autosubscribe.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
# @author Iván Todorovich <ivan.todorovich@gmail.com>
33
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
44

5-
from odoo_test_helper import FakeModelLoader
6-
5+
from odoo.orm.model_classes import add_to_registry
76
from odoo.tests import Form, tagged
87
from odoo.tests.common import TransactionCase
98

@@ -15,11 +14,12 @@ def setUpClass(cls):
1514
super().setUpClass()
1615
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
1716
# Load fake order model
18-
cls.loader = FakeModelLoader(cls.env, cls.__module__)
19-
cls.loader.backup_registry()
2017
from .models.fake_order import FakeOrder
2118

22-
cls.loader.update_registry((FakeOrder,))
19+
add_to_registry(cls.registry, FakeOrder)
20+
cls.registry._setup_models__(cls.env.cr, ["fake.order"])
21+
cls.registry.init_models(cls.env.cr, ["fake.order"], {"models_to_check": True})
22+
cls.addClassCleanup(cls.registry.__delitem__, "fake.order")
2323
cls.fake_order_model = cls.env["ir.model"].search(
2424
[("model", "=", "fake.order")]
2525
)
@@ -49,11 +49,6 @@ def setUpClass(cls):
4949
# Empty fake.order
5050
cls.order = cls.env["fake.order"].create({"partner_id": cls.partner_2.id})
5151

52-
@classmethod
53-
def tearDownClass(cls):
54-
cls.loader.restore_registry()
55-
return super().tearDownClass()
56-
5752
def test_message_subscribe(self):
5853
"""Test autosubscribe on a basic workflow"""
5954
self.assertFalse(self.order.message_partner_ids, "No subscribers yet")

0 commit comments

Comments
 (0)