[19.0][IMP] partner_email_check: clearer duplicate-email message + multi-company scope option#2374
Open
cliffkujala wants to merge 1 commit into
Open
Conversation
c3458f3 to
254455e
Compare
BhaveshHeliconia
approved these changes
Jun 1, 2026
Contributor
BhaveshHeliconia
left a comment
There was a problem hiding this comment.
Code and functional review LGTM!
| { | ||
| "name": "Restricted", | ||
| "login": "restricted_user", | ||
| "group_ids": [(6, 0, groups.ids)], |
Contributor
There was a problem hiding this comment.
Suggested change
| "group_ids": [(6, 0, groups.ids)], | |
| "group_ids": [Commad.set(groups.ids)], |
Author
There was a problem hiding this comment.
Thanks for the review! Good call on Command.set — much cleaner than the (6, 0, ...) tuple. Small heads-up: the suggestion as written has a typo (Commad.set), so I applied a corrected version manually: added from odoo import Command, switched this line to Command.set(groups.ids), and also converted the ir.rule groups line below to Command.set([]) for consistency. Pushed in the latest commit.
…mpany scope option
254455e to
debe00e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This improves the duplicate-email handling of
partner_email_checkin two ways: a clearer, access-aware error message, and a new option to scope uniqueness per company instead of globally.Clearer, access-aware duplicate message
The duplicate check is an
@api.constrains, which always runs as superuser, so uniqueness was (and still is) enforced across all records regardless of the acting user's record rules. Previously a collision raised a genericEmail 'x@y.com' is already in use., which is confusing when the user cannot see the conflicting partner (record rules / multi-company): they are blocked from using an address that appears nowhere they can look.After detecting a conflict, the constraint now re-checks whether the acting user can actually read the conflicting record (
self.sudo(False)) and tailors the message:Email address x@y.com is already in use by <name> (ID: 123). Please input another email address or use the existing record.Email address x@y.com is already in use by a record you do not have access to. Please input a different email address, or contact your system administrator to request access.Multi-company duplicate scope option
New company setting
partner_email_check_duplicate_scope(exposed in Settings, shown only when duplicate filtering is enabled):global, default) — unchanged behavior: an address may be used only once in the whole database.company) — the same address may be reused by a partner of another company, but must stay unique inside each company (company_id = Falseis treated as its own bucket).Compatibility notes
global, preserving the previous behavior.Tests
Adds coverage for: per-company scope allowing the same address in another company, per-company scope still blocking within one company, global scope blocking across companies, and the access-restricted message path (duplicate hidden by a record rule is still blocked, without leaking the record).