Skip to content

Commit 5510c81

Browse files
committed
[MIG] coop_mass_mailing_contact: Migration to 18.0
1 parent 5d9efe5 commit 5510c81

12 files changed

Lines changed: 670 additions & 53 deletions

File tree

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
======================
2+
Mass Mailing - Contact
3+
======================
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:a1cdbd38ce2b4cd713abaf33ca2b31b36ebd5f6aaf99f3f971a014f714df55ae
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-AwesomeFoodCoops%2Fodoo--production-lightgray.png?logo=github
20+
:target: https://github.com/AwesomeFoodCoops/odoo-production/tree/18.0/coop_mass_mailing_contact
21+
:alt: AwesomeFoodCoops/odoo-production
22+
23+
|badge1| |badge2| |badge3|
24+
25+
Automatically synchronize mailing list contacts with cooperative
26+
members.
27+
28+
This module adds an **Is Member Contact** flag on mailing lists. When
29+
enabled, the list is kept in sync with active cooperative members
30+
(``res.partner`` where ``is_member = True``):
31+
32+
- **Add contacts**: new members are automatically added to the mailing
33+
list as ``mailing.contact`` records.
34+
- **Remove contacts**: contacts whose partner is no longer a member are
35+
removed from the list.
36+
37+
The synchronization runs daily via a scheduled action, or can be
38+
triggered manually at any time.
39+
40+
**Table of contents**
41+
42+
.. contents::
43+
:local:
44+
45+
Configuration
46+
=============
47+
48+
1. Go to **Email Marketing → Mailing Lists** and open (or create) a
49+
mailing list.
50+
2. Enable the **Is Member Contact** checkbox to mark this list as
51+
member-managed.
52+
3. The scheduled action **"Mailing List: Add the contact from member"**
53+
is activated automatically upon module installation and runs daily at
54+
20:00. Adjust the schedule under **Settings → Technical → Automation
55+
→ Scheduled Actions** if needed.
56+
57+
Usage
58+
=====
59+
60+
Once a mailing list has **Is Member Contact** enabled:
61+
62+
- The list is synchronized automatically every day at 20:00.
63+
- New cooperative members (partners with ``is_member = True`` and a
64+
valid email) are added as contacts.
65+
- Contacts whose partner is no longer a member are removed from the
66+
list.
67+
68+
To trigger a manual sync at any time:
69+
70+
1. Go to **Settings → Technical → Automation → Scheduled Actions**.
71+
2. Find **"Mailing List: Add the contact from member"** and click **Run
72+
Manually**.
73+
3. Open the mailing list and click the **Recipients** stat button to
74+
confirm the contacts have been updated.
75+
76+
Bug Tracker
77+
===========
78+
79+
Bugs are tracked on `GitHub Issues <https://github.com/AwesomeFoodCoops/odoo-production/issues>`_.
80+
In case of trouble, please check there if your issue has already been reported.
81+
If you spotted it first, help us to smash it by providing a detailed and welcomed
82+
`feedback <https://github.com/AwesomeFoodCoops/odoo-production/issues/new?body=module:%20coop_mass_mailing_contact%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
83+
84+
Do not contact contributors directly about support or help with technical issues.
85+
86+
Credits
87+
=======
88+
89+
Authors
90+
-------
91+
92+
* La Louve
93+
* Trobz
94+
95+
Maintainers
96+
-----------
97+
98+
This module is part of the `AwesomeFoodCoops/odoo-production <https://github.com/AwesomeFoodCoops/odoo-production/tree/18.0/coop_mass_mailing_contact>`_ project on GitHub.
99+
100+
You are welcome to contribute.

coop_mass_mailing_contact/__manifest__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
{
88
"name": "Mass Mailing - Contact",
9-
"version": "12.0.1.0.0",
9+
"version": "18.0.1.0.0",
1010
"category": "Tools",
1111
"summary": "Create the contact for each member",
12-
"author": "Trobz",
12+
"author": "La Louve, Trobz",
1313
"website": "https://github.com/AwesomeFoodCoops/odoo-production",
1414
"depends": [
1515
"coop_membership",
Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
<?xml version="1.0" ?>
2-
<odoo>
3-
<data noupdate="1">
4-
<record model="ir.cron" id="cron_compute_contact">
5-
<field name="name">Mailing List: Add the contact from member</field>
6-
<field name="interval_number">1</field>
7-
<field name="interval_type">days</field>
8-
<field name="numbercall">-1</field>
9-
<field name="doall" eval="False" />
10-
<field
11-
name="model_id"
12-
ref="coop_mass_mailing_contact.model_mail_mass_mailing_list"
13-
/>
14-
<field name="code">model.cron_compute_contact()</field>
15-
<field name="state">code</field>
16-
<field
17-
name="nextcall"
18-
eval="DateTime.now().strftime('%Y-%m-%d 20:00:00')"
19-
/>
20-
</record>
21-
</data>
2+
<odoo noupdate="1">
3+
<record model="ir.cron" id="cron_compute_contact">
4+
<field name="name">Mailing List: Add the contact from member</field>
5+
<field name="interval_number">1</field>
6+
<field name="interval_type">days</field>
7+
<field name="model_id" ref="mass_mailing.model_mailing_list" />
8+
<field name="code">model.cron_compute_contact()</field>
9+
<field name="state">code</field>
10+
<field name="nextcall" eval="DateTime.now().strftime('%Y-%m-%d 20:00:00')" />
11+
</record>
2212
</odoo>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Translation of Odoo Server.
2+
# This file contains the translation of the following modules:
3+
# * coop_mass_mailing_contact
4+
#
5+
msgid ""
6+
msgstr ""
7+
"Project-Id-Version: Odoo Server 18.0+e\n"
8+
"Report-Msgid-Bugs-To: \n"
9+
"POT-Creation-Date: 2026-04-08 08:32+0000\n"
10+
"PO-Revision-Date: 2026-04-08 08:32+0000\n"
11+
"Last-Translator: \n"
12+
"Language-Team: \n"
13+
"MIME-Version: 1.0\n"
14+
"Content-Type: text/plain; charset=UTF-8\n"
15+
"Content-Transfer-Encoding: \n"
16+
"Plural-Forms: \n"
17+
18+
#. module: coop_mass_mailing_contact
19+
#: model:ir.model.fields,field_description:coop_mass_mailing_contact.field_mailing_contact__is_member_contact
20+
#: model:ir.model.fields,field_description:coop_mass_mailing_contact.field_mailing_list__is_member_contact
21+
msgid "Is Member Contact"
22+
msgstr "Est un contact membre"
23+
24+
#. module: coop_mass_mailing_contact
25+
#: model:ir.model,name:coop_mass_mailing_contact.model_mailing_contact
26+
msgid "Mailing Contact"
27+
msgstr "Contact de diffusion"
28+
29+
#. module: coop_mass_mailing_contact
30+
#: model:ir.model,name:coop_mass_mailing_contact.model_mailing_list
31+
msgid "Mailing List"
32+
msgstr "Liste de diffusion"
33+
34+
#. module: coop_mass_mailing_contact
35+
#: model:ir.actions.server,name:coop_mass_mailing_contact.cron_compute_contact_ir_actions_server
36+
msgid "Mailing List: Add the contact from member"
37+
msgstr "Liste de diffusion : ajouter les contacts des membres"
38+
39+
#. module: coop_mass_mailing_contact
40+
#: model:ir.model.fields,help:coop_mass_mailing_contact.field_mailing_list__is_member_contact
41+
msgid "Populate the contact from the members"
42+
msgstr "Ajouter automatiquement les contacts à partir des membres"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from . import mass_mailing_contact
2-
from . import mass_mailing
1+
from . import mailing_contact
2+
from . import mailing_list

coop_mass_mailing_contact/models/mass_mailing_contact.py renamed to coop_mass_mailing_contact/models/mailing_contact.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from odoo import fields, models
22

33

4-
class MassMailingContact(models.Model):
5-
_inherit = "mail.mass_mailing.contact"
4+
class MailingContact(models.Model):
5+
_inherit = "mailing.contact"
66

77
is_member_contact = fields.Boolean(default=False)
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from odoo import api, fields, models
1+
from odoo import api, fields, models, Command
22

33

4-
class MassMailingList(models.Model):
5-
_inherit = "mail.mass_mailing.list"
4+
class MailingList(models.Model):
5+
_inherit = "mailing.list"
66

77
is_member_contact = fields.Boolean(
88
default=False, help="Populate the contact from the members"
@@ -16,20 +16,20 @@ def remove_contacts(self):
1616
if not self:
1717
return
1818
sql = f"""
19-
DELETE FROM mail_mass_mailing_contact_list_rel
19+
DELETE FROM mailing_subscription
2020
WHERE id IN (
21-
SELECT ctr.id
22-
FROM mail_mass_mailing_contact ct
23-
JOIN mail_mass_mailing_contact_list_rel ctr
24-
ON ctr.contact_id = ct.id
21+
SELECT ms.id
22+
FROM mailing_contact ct
23+
JOIN mailing_subscription ms
24+
ON ms.contact_id = ct.id
2525
JOIN (
2626
SELECT DISTINCT ON (email) id, email, is_member
2727
FROM res_partner
2828
ORDER BY email, is_member DESC NULLS LAST
2929
) rp
3030
ON rp.email = ct.email
3131
WHERE rp.is_member IS FALSE
32-
AND ctr.list_id in {str(tuple(self.ids + [-1]))}
32+
AND ms.list_id in {str(tuple(self.ids + [-1]))}
3333
)
3434
"""
3535
self._cr.execute(sql)
@@ -38,12 +38,12 @@ def add_contacts(self, limit=1000):
3838
if not self:
3939
return
4040
sql = f"""
41-
SELECT rp.id, rp.name, rp.email, rp.opt_out
41+
SELECT rp.id, rp.name, rp.email
4242
FROM res_partner rp
43-
LEFT JOIN mail_mass_mailing_contact ct
43+
LEFT JOIN mailing_contact ct
4444
ON rp.email = ct.email
45-
WHERE ct.id ISNULL
46-
AND rp.email NOTNULL
45+
WHERE ct.id IS NULL
46+
AND rp.email IS NOT NULL
4747
AND rp.is_member IS TRUE
4848
LIMIT {limit}
4949
"""
@@ -54,13 +54,13 @@ def add_contacts(self, limit=1000):
5454
"name": data[1],
5555
"email": data[2],
5656
"is_member_contact": True,
57-
"subscription_list_ids": [],
57+
"subscription_ids": [],
5858
}
59-
for list in self:
60-
vals["subscription_list_ids"].append(
61-
(0, 0, {"list_id": list.id, "opt_out": data[3]})
59+
for mailing_list in self:
60+
vals["subscription_ids"].append(
61+
Command.create({"list_id": mailing_list.id, "opt_out": False})
6262
)
63-
contact = self.env["mail.mass_mailing.contact"].create(vals)
63+
self.env["mailing.contact"].create(vals)
6464

6565
@api.model
6666
def cron_compute_contact(self, limit=1000):
@@ -69,5 +69,5 @@ def cron_compute_contact(self, limit=1000):
6969
- Remove the contact which not the member anymore
7070
- Create new contact for a new member
7171
"""
72-
list = self.search([("is_member_contact", "=", True)])
73-
list.compute_contacts(limit)
72+
mailing_lists = self.search([("is_member_contact", "=", True)])
73+
mailing_lists.compute_contacts(limit)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
1. Go to **Email Marketing → Mailing Lists** and open (or create) a mailing list.
2+
2. Enable the **Is Member Contact** checkbox to mark this list as member-managed.
3+
3. The scheduled action **"Mailing List: Add the contact from member"** is
4+
activated automatically upon module installation and runs daily at 20:00.
5+
Adjust the schedule under
6+
**Settings → Technical → Automation → Scheduled Actions** if needed.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Automatically synchronize mailing list contacts with cooperative members.
2+
3+
This module adds an **Is Member Contact** flag on mailing lists. When enabled,
4+
the list is kept in sync with active cooperative members (`res.partner` where
5+
`is_member = True`):
6+
7+
- **Add contacts**: new members are automatically added to the mailing list as
8+
`mailing.contact` records.
9+
- **Remove contacts**: contacts whose partner is no longer a member are
10+
removed from the list.
11+
12+
The synchronization runs daily via a scheduled action, or can be triggered
13+
manually at any time.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Once a mailing list has **Is Member Contact** enabled:
2+
3+
- The list is synchronized automatically every day at 20:00.
4+
- New cooperative members (partners with `is_member = True` and a valid email)
5+
are added as contacts.
6+
- Contacts whose partner is no longer a member are removed from the list.
7+
8+
To trigger a manual sync at any time:
9+
10+
1. Go to **Settings → Technical → Automation → Scheduled Actions**.
11+
2. Find **"Mailing List: Add the contact from member"** and click **Run Manually**.
12+
3. Open the mailing list and click the **Recipients** stat button to confirm
13+
the contacts have been updated.

0 commit comments

Comments
 (0)