Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
# Copyright - 2013-2024 Therp BV <https://therp.nl>.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import email_exact
from . import email_domain

View File

@@ -0,0 +1,29 @@
# Copyright - 2013-2024 Therp BV <https://therp.nl>.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from .email_exact import EmailExact
class EmailDomain(EmailExact):
"""Search objects by domain name of email address.
Beware of match_first here, this is most likely to get it wrong (gmail).
"""
def search_matches(self, folder, message_dict):
"""Returns recordset of matching objects."""
matches = super().search_matches(folder, message_dict)
if not matches:
object_model = folder.env[folder.model_id.model]
domains = []
for addr in self._get_mailaddresses(folder, message_dict):
domains.append(addr.split("@")[-1])
matches = object_model.search(
self._get_mailaddress_search_domain(
folder,
message_dict,
operator="like",
values=["%@" + domain for domain in set(domains)],
),
order=folder.model_order,
)
return matches

View File

@@ -0,0 +1,35 @@
# Copyright - 2013-2024 Therp BV <https://therp.nl>.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo.tools.mail import email_split
from odoo.tools.safe_eval import safe_eval
class EmailExact:
"""Search for exactly the mailadress as noted in the email"""
def _get_mailaddresses(self, folder, message_dict):
mailaddresses = []
fields = folder.mail_field.split(",")
for field in fields:
if field in message_dict:
mailaddresses += email_split(message_dict[field])
return [addr.lower() for addr in mailaddresses]
def _get_mailaddress_search_domain(
self, folder, message_dict, operator="=", values=None
):
mailaddresses = values or self._get_mailaddresses(folder, message_dict)
if not mailaddresses:
return [(0, "=", 1)]
search_domain = (
(["|"] * (len(mailaddresses) - 1))
+ [(folder.model_field, operator, addr) for addr in mailaddresses]
+ safe_eval(folder.domain or "[]")
)
return search_domain
def search_matches(self, folder, message_dict):
"""Returns recordset of matching objects."""
object_model = folder.env[folder.model_id.model]
search_domain = self._get_mailaddress_search_domain(folder, message_dict)
return object_model.search(search_domain, order=folder.model_order)