diff --git a/mass_mailing_event_registration_exclude/README.rst b/mass_mailing_event_registration_exclude/README.rst index df16d1a333..d163028270 100644 --- a/mass_mailing_event_registration_exclude/README.rst +++ b/mass_mailing_event_registration_exclude/README.rst @@ -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 @@ -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| @@ -62,7 +62,7 @@ Bug Tracker Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -83,6 +83,7 @@ Contributors * David Vidal * Alexandre D. Díaz * Stefan Ungureanu + * Carolina Fernandez Maintainers ~~~~~~~~~~~ @@ -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 `_ project on GitHub. +This module is part of the `OCA/social `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/mass_mailing_event_registration_exclude/models/event_registration.py b/mass_mailing_event_registration_exclude/models/event_registration.py index 1b18899104..8309e9620b 100644 --- a/mass_mailing_event_registration_exclude/models/event_registration.py +++ b/mass_mailing_event_registration_exclude/models/event_registration.py @@ -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 diff --git a/mass_mailing_event_registration_exclude/models/mailing.py b/mass_mailing_event_registration_exclude/models/mailing.py index 05be4fdd62..4080cdd62f 100644 --- a/mass_mailing_event_registration_exclude/models/mailing.py +++ b/mass_mailing_event_registration_exclude/models/mailing.py @@ -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([]) @@ -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 diff --git a/mass_mailing_event_registration_exclude/models/mailing_contact.py b/mass_mailing_event_registration_exclude/models/mailing_contact.py index 26eaa4d6c1..acd0675e6b 100644 --- a/mass_mailing_event_registration_exclude/models/mailing_contact.py +++ b/mass_mailing_event_registration_exclude/models/mailing_contact.py @@ -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 diff --git a/mass_mailing_event_registration_exclude/models/res_partner.py b/mass_mailing_event_registration_exclude/models/res_partner.py index fdeebf97c1..1306b7fd71 100644 --- a/mass_mailing_event_registration_exclude/models/res_partner.py +++ b/mass_mailing_event_registration_exclude/models/res_partner.py @@ -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 diff --git a/mass_mailing_event_registration_exclude/static/description/index.html b/mass_mailing_event_registration_exclude/static/description/index.html index 7c490c1770..1d8db0e3c1 100644 --- a/mass_mailing_event_registration_exclude/static/description/index.html +++ b/mass_mailing_event_registration_exclude/static/description/index.html @@ -367,9 +367,9 @@

Mass mailing event

!! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:88408a0f1d9122cec41d99c00f3edcfd7a0e6de94aa3520afb2e2953d6460748 +!! source digest: sha256:a2fd89c0a593672ecc127e763e00e1602b770b4b305eae54e779ff71d091f321 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/social Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/social Translate me on Weblate Try me on Runboat

This module links mass_mailing with event in order to exclude recipients that are already registered, confirmed, cancelled, attended, or a combination of these states, when the mass mailing is sent.

@@ -407,7 +407,7 @@

Bug Tracker

Bugs are tracked on GitHub 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.

+feedback.

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

@@ -441,7 +441,7 @@

Maintainers

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 project on GitHub.

+

This module is part of the OCA/social project on GitHub.

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