Browse Source
Add normalization and optional uniqueness to partner_email_check
Add normalization and optional uniqueness to partner_email_check
- partner_email_check now uses email-validator instead of validate_email - Email addresses are normalized - There is a setting to enforce uniqueness of partner email addresses - There is a setting to check whether emails are deliverable (i.e. whether the domain resolves)14.0
Jan Verbeek
5 years ago
committed by
Zar21
7 changed files with 302 additions and 19 deletions
-
19partner_email_check/README.rst
-
7partner_email_check/__manifest__.py
-
1partner_email_check/models/__init__.py
-
42partner_email_check/models/res_config_settings.py
-
85partner_email_check/models/res_partner.py
-
126partner_email_check/tests/test_partner_email_check.py
-
39partner_email_check/views/base_config_view.xml
@ -1,3 +1,4 @@ |
|||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). |
|||
|
|||
from . import res_config_settings |
|||
from . import res_partner |
@ -0,0 +1,42 @@ |
|||
from odoo import api, 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.", |
|||
) |
|||
|
|||
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", |
|||
) |
|||
|
|||
@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 |
|||
|
|||
@api.multi |
|||
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 |
|||
) |
@ -0,0 +1,39 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<record id="view_general_configuration" model="ir.ui.view"> |
|||
<field name="name">partner_email_check</field> |
|||
<field name="model">res.config.settings</field> |
|||
<field name="inherit_id" |
|||
ref="base_setup.res_config_settings_view_form" /> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//div[@name='multi_company']" position='after'> |
|||
<h2>Email validation</h2> |
|||
<div class="row mt16 o_settings_container" |
|||
name="partner_email_check"> |
|||
<div class="col-xs-12 col-md-6 o_setting_box"> |
|||
<div class="o_setting_left_pane"> |
|||
<field name="partner_email_check_filter_duplicates" /> |
|||
</div> |
|||
<div class="o_setting_right_pane"> |
|||
<label for="partner_email_check_filter_duplicates" /> |
|||
<div class="text-muted"> |
|||
Require partner email addresses to be unique |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="col-xs-12 col-md-6 o_setting_box"> |
|||
<div class="o_setting_left_pane"> |
|||
<field name="partner_email_check_check_deliverability" /> |
|||
</div> |
|||
<div class="o_setting_right_pane"> |
|||
<label for="partner_email_check_check_deliverability" /> |
|||
<div class="text-muted"> |
|||
Ensure that partner email addresses can be delivered to |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue