Browse Source
[FIX] Remove email from copy data if duplicates not allowed
[FIX] Remove email from copy data if duplicates not allowed
[REF] Partner email chack params on company [IMP] email_check [IMP] test partner_email_check use SavepointCase14.0
Quentin Groulard
4 years ago
committed by
Zar21
7 changed files with 90 additions and 70 deletions
-
24partner_email_check/migrations/13.0.1.0.0/post-migration.py
-
1partner_email_check/models/__init__.py
-
18partner_email_check/models/res_company.py
-
36partner_email_check/models/res_config_settings.py
-
25partner_email_check/models/res_partner.py
-
42partner_email_check/tests/test_partner_email_check.py
-
14partner_email_check/views/base_config_view.xml
@ -0,0 +1,24 @@ |
|||
# Copyright 2021 ACSONE SA/NV |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). |
|||
|
|||
from openupgradelib import openupgrade |
|||
|
|||
|
|||
@openupgrade.migrate(use_env=True) |
|||
def migrate(env, version): |
|||
param_duplicate = env["ir.config_parameter"].search( |
|||
[("key", "=", "partner_email_check_filter_duplicates")] |
|||
) |
|||
if param_duplicate: |
|||
env["res.company"].search([]).write( |
|||
{"partner_email_check_filter_duplicates": param_duplicate.value} |
|||
) |
|||
param_duplicate.unlink() |
|||
param_deliverability = env["ir.config_parameter"].search( |
|||
[("key", "=", "partner_email_check_check_deliverability")] |
|||
) |
|||
if param_deliverability: |
|||
env["res.company"].search([]).write( |
|||
{"partner_email_check_check_deliverability": param_deliverability.value} |
|||
) |
|||
param_deliverability.unlink() |
@ -1,4 +1,5 @@ |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). |
|||
|
|||
from . import res_company |
|||
from . import res_config_settings |
|||
from . import res_partner |
@ -0,0 +1,18 @@ |
|||
# Copyright 2021 ACSONE SA/NV |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). |
|||
|
|||
from odoo import fields, models |
|||
|
|||
|
|||
class ResCompany(models.Model): |
|||
|
|||
_inherit = "res.company" |
|||
|
|||
partner_email_check_filter_duplicates = fields.Boolean( |
|||
string="Filter duplicate partner email addresses", |
|||
help="Don't allow multiple partners to have the same email address.", |
|||
) |
|||
partner_email_check_check_deliverability = fields.Boolean( |
|||
string="Check deliverability of email addresses", |
|||
help="Don't allow email addresses with providers that don't exist", |
|||
) |
@ -1,43 +1,13 @@ |
|||
from odoo import api, fields, models |
|||
from odoo import fields, models |
|||
|
|||
|
|||
class ResConfigSettings(models.TransientModel): |
|||
_inherit = "res.config.settings" |
|||
|
|||
partner_email_check_filter_duplicates = fields.Boolean( |
|||
string="Filter duplicate partner email addresses", |
|||
help="Don't allow multiple partners to have the same email address.", |
|||
related="company_id.partner_email_check_filter_duplicates", readonly=False, |
|||
) |
|||
|
|||
partner_email_check_check_deliverability = fields.Boolean( |
|||
string="Check deliverability of email addresses", |
|||
help="Don't allow email addresses with providers that don't exist", |
|||
related="company_id.partner_email_check_check_deliverability", readonly=False, |
|||
) |
|||
|
|||
@api.model |
|||
def get_values(self): |
|||
res = super(ResConfigSettings, self).get_values() |
|||
conf = self.env["ir.config_parameter"].sudo() |
|||
res.update( |
|||
partner_email_check_filter_duplicates=conf.get_param( |
|||
"partner_email_check_filter_duplicates", "False" |
|||
) |
|||
== "True", |
|||
partner_email_check_check_deliverability=conf.get_param( |
|||
"partner_email_check_check_deliverability", "False" |
|||
) |
|||
== "True", |
|||
) |
|||
return res |
|||
|
|||
def set_values(self): |
|||
super(ResConfigSettings, self).set_values() |
|||
conf = self.env["ir.config_parameter"].sudo() |
|||
conf.set_param( |
|||
"partner_email_check_filter_duplicates", |
|||
self.partner_email_check_filter_duplicates, |
|||
) |
|||
conf.set_param( |
|||
"partner_email_check_check_deliverability", |
|||
self.partner_email_check_check_deliverability, |
|||
) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue