fix: Убраны зависимости от iap

Changelog: fixed
This commit is contained in:
cen9 2024-07-04 13:04:15 +03:00
parent 5137613d51
commit 264a9af7bf
2 changed files with 2 additions and 43 deletions

View File

@ -11,7 +11,6 @@ from markupsafe import Markup
from psycopg2 import sql from psycopg2 import sql
from odoo import api, fields, models, tools, SUPERUSER_ID from odoo import api, fields, models, tools, SUPERUSER_ID
from odoo.addons.iap.tools import iap_tools
from odoo.addons.mail.tools import mail_validation from odoo.addons.mail.tools import mail_validation
from odoo.addons.phone_validation.tools import phone_validation from odoo.addons.phone_validation.tools import phone_validation
from odoo.exceptions import UserError, AccessError from odoo.exceptions import UserError, AccessError
@ -189,13 +188,6 @@ class Lead(models.Model):
'Email', tracking=40, index='trigram', 'Email', tracking=40, index='trigram',
compute='_compute_email_from', inverse='_inverse_email_from', readonly=False, store=True) compute='_compute_email_from', inverse='_inverse_email_from', readonly=False, store=True)
email_normalized = fields.Char(index='trigram') # inherited via mail.thread.blacklist email_normalized = fields.Char(index='trigram') # inherited via mail.thread.blacklist
email_domain_criterion = fields.Char(
string='Email Domain Criterion',
compute="_compute_email_domain_criterion",
index='btree_not_null', # used for exact match, void value do not matter
store=True,
unaccent=False, # normalized, exact matching
)
phone = fields.Char( phone = fields.Char(
'Phone', tracking=50, 'Phone', tracking=50,
compute='_compute_phone', inverse='_inverse_phone', readonly=False, store=True) compute='_compute_phone', inverse='_inverse_phone', readonly=False, store=True)
@ -460,14 +452,6 @@ class Lead(models.Model):
if lead._get_partner_email_update(): if lead._get_partner_email_update():
lead.partner_id.email = lead.email_from lead.partner_id.email = lead.email_from
@api.depends('email_normalized')
def _compute_email_domain_criterion(self):
self.email_domain_criterion = False
for lead in self.filtered('email_normalized'):
lead.email_domain_criterion = iap_tools.mail_prepare_for_domain_search(
lead.email_normalized
)
@api.depends('partner_id.phone') @api.depends('partner_id.phone')
def _compute_phone(self): def _compute_phone(self):
for lead in self: for lead in self:
@ -565,7 +549,7 @@ class Lead(models.Model):
lead.meeting_display_date = lead_meeting_info['last_meeting_date'] lead.meeting_display_date = lead_meeting_info['last_meeting_date']
lead.meeting_display_label = _('Last Meeting') lead.meeting_display_label = _('Last Meeting')
@api.depends('email_domain_criterion', 'email_normalized', 'partner_id', @api.depends('email_normalized', 'partner_id',
'phone_sanitized') 'phone_sanitized')
def _compute_potential_lead_duplicates(self): def _compute_potential_lead_duplicates(self):
""" Override potential lead duplicates computation to be more efficient """ Override potential lead duplicates computation to be more efficient
@ -601,11 +585,6 @@ class Lead(models.Model):
duplicate_lead_ids = self.env['crm.lead'] duplicate_lead_ids = self.env['crm.lead']
# check the "company" email domain duplicates
if lead.email_domain_criterion:
duplicate_lead_ids |= return_if_relevant('crm.lead', common_lead_domain + [
('email_domain_criterion', '=', lead.email_domain_criterion)
])
# check for "same commercial entity" duplicates # check for "same commercial entity" duplicates
if lead.partner_id and lead.partner_id.commercial_partner_id: if lead.partner_id and lead.partner_id.commercial_partner_id:
duplicate_lead_ids |= lead.with_context(active_test=False).search(common_lead_domain + [ duplicate_lead_ids |= lead.with_context(active_test=False).search(common_lead_domain + [

View File

@ -2,7 +2,6 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details. # Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo.addons.crm.tests.common import TestCrmCommon from odoo.addons.crm.tests.common import TestCrmCommon
from odoo.addons.iap.tools import iap_tools
from odoo.tests.common import tagged, users from odoo.tests.common import tagged, users
@ -209,23 +208,4 @@ class TestCRMLead(TestCrmCommon):
'email_from': test_email, 'email_from': test_email,
'name': test_email, 'name': test_email,
}) })
self.assertEqual(lead.email_domain_criterion, f'@{provider}',) self.assertEqual(lead.email_domain_criterion, f'@{provider}',)
@users('user_sales_leads')
def test_iap_tools(self):
""" Test iap tools specifically """
for test_email, provider in self.emails_provider_generic:
with self.subTest(test_email=test_email, provider=provider):
self.assertEqual(
iap_tools.mail_prepare_for_domain_search(test_email),
test_email,
'As provider is a generic one, complete email should be returned for a company-based mail search'
)
for test_email, provider in self.emails_provider_company:
with self.subTest(test_email=test_email, provider=provider):
self.assertEqual(
iap_tools.mail_prepare_for_domain_search(test_email),
f'@{provider}',
'As provider is a company one, only the domain part should be returned for a company-based mail search'
)