Skip to content

Commit

Permalink
[MIG] mass_mailing_event_registration_exclude: Continue Migration to …
Browse files Browse the repository at this point in the history
…16.0
  • Loading branch information
carolinafernandez-tecnativa committed Jan 4, 2024
1 parent 7998b89 commit 10a6675
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 48 deletions.
13 changes: 7 additions & 6 deletions mass_mailing_event_registration_exclude/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Mass mailing event
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:88408a0f1d9122cec41d99c00f3edcfd7a0e6de94aa3520afb2e2953d6460748
!! source digest: sha256:a2fd89c0a593672ecc127e763e00e1602b770b4b305eae54e779ff71d091f321
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -17,13 +17,13 @@ Mass mailing event
: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/15.0/mass_mailing_event_registration_exclude
:target: https://github.com/OCA/social/tree/16.0/mass_mailing_event_registration_exclude
:alt: OCA/social
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/social-15-0/social-15-0-mass_mailing_event_registration_exclude
:target: https://translation.odoo-community.org/projects/social-16-0/social-16-0-mass_mailing_event_registration_exclude
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=15.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/social&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -62,7 +62,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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/social/issues/new?body=module:%20mass_mailing_event_registration_exclude%0Aversion:%2015.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:%20mass_mailing_event_registration_exclude%0Aversion:%2016.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 All @@ -83,6 +83,7 @@ Contributors
* David Vidal
* Alexandre D. Díaz
* Stefan Ungureanu
* Carolina Fernandez

Maintainers
~~~~~~~~~~~
Expand All @@ -97,6 +98,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

from odoo import api, models

from .mailing import event_filtered_ids


class EventRegistration(models.Model):
_inherit = "event.registration"

@api.model
def search_count(self, domain, limit=None):
res = super().search_count(domain)
res = super().search_count(domain, limit=limit)
mass_mailing_id = self.env.context.get("exclude_mass_mailing", False)
if mass_mailing_id:
res_ids = event_filtered_ids(self, mass_mailing_id, domain, field="email")
res_ids = self.env["mailing.mailing"].event_filtered_ids(
self, mass_mailing_id, domain, field="email"
)
res = len(res_ids) if res_ids else 0
return res
51 changes: 25 additions & 26 deletions mass_mailing_event_registration_exclude/models/mailing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,33 @@
from odoo import fields, models


def event_filtered_ids(model, mailing_mailing_id, domain, field="email"):
field = field or "email"
domain = domain or []
exclude_emails = []
mailing_mailing = model.env["mailing.mailing"].browse(mailing_mailing_id)
if mailing_mailing.event_id:
exclude = mailing_mailing.exclude_event_state_ids.mapped("code")
reg_domain = False
registrations = model.env["event.registration"]
if exclude:
reg_domain = [
("event_id", "=", mailing_mailing.event_id.id),
("state", "in", exclude),
]
if reg_domain:
registrations = registrations.search(reg_domain)
if registrations:
exclude_emails = registrations.mapped("email")
apply_domain = copy.deepcopy(domain)
if exclude_emails:
apply_domain.append((field, "not in", exclude_emails))
rows = model.search(apply_domain)
return rows.ids


class MassMailing(models.Model):
_inherit = "mailing.mailing"

def event_filtered_ids(self, model, mailing_mailing_id, domain, field="email"):
field = field or "email"
domain = domain or []
exclude_emails = []
mailing_mailing = model.env["mailing.mailing"].browse(mailing_mailing_id)
if mailing_mailing.event_id:
exclude = mailing_mailing.exclude_event_state_ids.mapped("code")
reg_domain = False
registrations = model.env["event.registration"]
if exclude:
reg_domain = [
("event_id", "=", mailing_mailing.event_id.id),
("state", "in", exclude),
]
if reg_domain:
registrations = registrations.search(reg_domain)
if registrations:
exclude_emails = registrations.mapped("email")
apply_domain = copy.deepcopy(domain)
if exclude_emails:
apply_domain.append((field, "not in", exclude_emails))
rows = model.search(apply_domain)
return rows.ids

def _default_exclude_event_state_ids(self):
return self.env["event.registration.state"].search([])

Expand All @@ -48,7 +47,7 @@ def _get_recipients(self):
res_ids = super()._get_recipients()
if res_ids:
domain = [("id", "in", res_ids)]
res_ids = event_filtered_ids(
res_ids = self.event_filtered_ids(
self.env[self.mailing_model_real], self.id, domain, field="email"
)
return res_ids
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

from odoo import api, models

from .mailing import event_filtered_ids


class MassMailingContact(models.Model):
_inherit = "mailing.contact"

@api.model
def search_count(self, domain, limit=None):
res = super().search_count(domain)
res = super().search_count(domain, limit=limit)
mass_mailing_id = self.env.context.get("exclude_mass_mailing", False)
if mass_mailing_id:
res_ids = event_filtered_ids(self, mass_mailing_id, domain, field="email")
res_ids = self.env["mailing.mailing"].event_filtered_ids(
self, mass_mailing_id, domain, field="email"
)
res = len(res_ids) if res_ids else 0
return res
8 changes: 4 additions & 4 deletions mass_mailing_event_registration_exclude/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

from odoo import api, models

from .mailing import event_filtered_ids


class ResPartner(models.Model):
_inherit = "res.partner"

@api.model
def search_count(self, domain, limit=None):
res = super().search_count(domain)
res = super().search_count(domain, limit=limit)
mass_mailing_id = self.env.context.get("exclude_mass_mailing", False)
if mass_mailing_id:
res_ids = event_filtered_ids(self, mass_mailing_id, domain, field="email")
res_ids = self.env["mailing.mailing"].event_filtered_ids(
self, mass_mailing_id, domain, field="email"
)
res = len(res_ids) if res_ids else 0
return res
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ <h1 class="title">Mass mailing event</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:88408a0f1d9122cec41d99c00f3edcfd7a0e6de94aa3520afb2e2953d6460748
!! source digest: sha256:a2fd89c0a593672ecc127e763e00e1602b770b4b305eae54e779ff71d091f321
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/social/tree/15.0/mass_mailing_event_registration_exclude"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/social-15-0/social-15-0-mass_mailing_event_registration_exclude"><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/social&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<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/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/social/tree/16.0/mass_mailing_event_registration_exclude"><img alt="OCA/social" src="https://img.shields.io/badge/github-OCA%2Fsocial-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/social-16-0/social-16-0-mass_mailing_event_registration_exclude"><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/social&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module links <tt class="docutils literal">mass_mailing</tt> with <tt class="docutils literal">event</tt> in order to exclude
recipients that are already registered, confirmed, cancelled, attended, or a
combination of these states, when the mass mailing is sent.</p>
Expand Down Expand Up @@ -407,7 +407,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">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 to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/social/issues/new?body=module:%20mass_mailing_event_registration_exclude%0Aversion:%2015.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:%20mass_mailing_event_registration_exclude%0Aversion:%2016.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 @@ -441,7 +441,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/social/tree/15.0/mass_mailing_event_registration_exclude">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/16.0/mass_mailing_event_registration_exclude">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

0 comments on commit 10a6675

Please sign in to comment.