Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13.0][MIG] partner_email_check: Migration to 13.0 #989

Merged
merged 16 commits into from
Jul 8, 2021

Conversation

qgroulard
Copy link
Contributor

No description provided.

denislour and others added 13 commits October 15, 2020 17:01
* Add new module partner-email-check
Validate email input
…en importing validate_email in 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)
portal's tests set an invalid email address, `c@c`, that's rejected
by the current version of partner_email_check. If partner_email_check
is installed before portal's tests run then they fail.

To solve this, skip email validation if tests are running, unless a
key in the context is set to make the checks run anyway. That lets
tests in other addons opt in to the checks as well.

The previous update to partner_email_check didn't bump the version
number, so do that now.
@qgroulard qgroulard changed the title [MIG] partner_email_check: Migration to 13.0 [13.0][MIG] partner_email_check: Migration to 13.0 Oct 15, 2020
@qgroulard qgroulard force-pushed the 13.0-mig-partner_email_check-qgr branch 2 times, most recently from 41c0e13 to 4bbf9a7 Compare October 16, 2020 07:46
@qgroulard qgroulard mentioned this pull request Oct 16, 2020
47 tasks
@qgroulard qgroulard force-pushed the 13.0-mig-partner_email_check-qgr branch 4 times, most recently from 117fdd9 to e40fa9c Compare October 16, 2020 09:34
@qgroulard qgroulard force-pushed the 13.0-mig-partner_email_check-qgr branch from e40fa9c to e356c0f Compare October 16, 2020 09:40
@kos94ok-3D
Copy link
Contributor

Not allowed duplicate partner with filled email so maybe need set copy=False or if _should_filter_duplicates remove email from copy_data


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.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
help="Don't allow multiple partners to have the same email address.",
help="Don't allow multiple partners to have the same email address.",
config_parameter="partner_email_check_filter_duplicates"

partner_email_check/models/res_config_settings.py Outdated Show resolved Hide resolved
partner_email_check/models/res_partner.py Outdated Show resolved Hide resolved
partner_email_check/models/res_partner.py Outdated Show resolved Hide resolved
partner_email_check/tests/test_partner_email_check.py Outdated Show resolved Hide resolved
@rousseldenis
Copy link
Contributor

@qgroulard Could you attend comments?

@qgroulard
Copy link
Contributor Author

@qgroulard Could you attend comments?

Yes I am trying to squeeze this in today's agenda but I'm afraid it will be for another day.
I'll work on this asap.

if self._should_filter_duplicates():
for copy_vals in res:
if "email" in copy_vals:
copy_vals["email"] = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not delete the value from the dictionary, or set it to False, so email will have a NULL value in the database.

@qgroulard qgroulard force-pushed the 13.0-mig-partner_email_check-qgr branch 2 times, most recently from 3864e32 to e3dfcc8 Compare July 6, 2021 15:33
Copy link
Contributor

@NL66278 NL66278 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@rousseldenis
Copy link
Contributor

@simahawk Could you update your review?

Comment on lines 30 to 32
for copy_vals in res:
if "email" in copy_vals:
del copy_vals["email"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a blocker but you could do:

Suggested change
for copy_vals in res:
if "email" in copy_vals:
del copy_vals["email"]
for copy_vals in res:
copy_vals.pop("email", None)


@api.model
def email_check(self, emails):
if config["test_enable"] and not self.env.context.get(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need this? What's the main reason?

def setUpClass(cls):
super().setUpClass()
cls.env = cls.env(context=dict(cls.env.context, tracking_disable=True))
# Checks are disabled during tests unless this key is set
Copy link
Contributor

@simahawk simahawk Jul 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get why we need this ctx key 🤔
Checks should be disabled by the flags set on the company.
If you want to keep them ON by default you can set them OFF in tests for the rest of the world by adding demo data 😉

Copy link
Contributor Author

@qgroulard qgroulard Jul 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually the same comment as #989 (comment) since this key is only used there.

I think I get it now...

There are actually 3 checks performed:

So I guess the idea is not to break other modules' tests since not having this context key set (and being in test mode) is the only way not to check emails syntax.

Maybe the solution would be to add a third flag for the syntax check.
It should be off by default otherwise other modules' test may fail. Thus users must be aware that behavior changes with v13 since beforehand this check used to always be performed.

What do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, the solution is simpler and I reported it above 😉

Just do this:

  1. add demo data file
  2. in that file call write function on all companies
  3. set the flags to false
  4. in your test class enable the flags

This way for the rest of the test suites (referred as "rest of the world" above) won't be impacted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course, the alternative is that you make the flag false by default and you state in the README that it should be enabled

@@ -0,0 +1,24 @@
# Copyright 2021 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it https:

[REF] Partner email chack params on company

[IMP] email_check

[IMP] test partner_email_check use SavepointCase
@qgroulard qgroulard force-pushed the 13.0-mig-partner_email_check-qgr branch from e3dfcc8 to 1aa74d9 Compare July 7, 2021 16:01
@qgroulard qgroulard force-pushed the 13.0-mig-partner_email_check-qgr branch from 1aa74d9 to f42ad2f Compare July 7, 2021 16:07
Copy link
Contributor

@simahawk simahawk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your changes!

@simahawk
Copy link
Contributor

simahawk commented Jul 8, 2021

/ocabot merge minor

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 13.0-ocabot-merge-pr-989-by-simahawk-bump-minor, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 9f45f5a into OCA:13.0 Jul 8, 2021
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 5578b86. Thanks a lot for contributing to OCA. ❤️

CLaurelB pushed a commit to vauxoo-dev/partner-contact that referenced this pull request Mar 6, 2024
Signed-off-by pedrobaeza
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.