[19.0][IMP] partner_email_duplicate_warn: access-aware duplicate banner#2375
[19.0][IMP] partner_email_duplicate_warn: access-aware duplicate banner#2375cliffkujala wants to merge 1 commit into
Conversation
The same_email_partner_ids field is computed as superuser (compute_sudo),
so it could include partners the acting user is not allowed to read. The
warning banner renders those records through the x2many_links widget, which
fetches their display_name as the current user, raising a raw AccessError
("you do not have read access") with no explanation when a duplicate is
hidden by record rules.
Only readable duplicates are now exposed as links. Partners with the same
email that the user cannot access are counted in a new
same_email_inaccessible_count field, and the banner shows a dedicated
message inviting the user to contact an administrator, without disclosing
the inaccessible records.
|
Hi @alexis-via, |
BhaveshHeliconia
left a comment
There was a problem hiding this comment.
@cliffkujala Could you guide me no how I can reproduce this issue? I've tried with some ways, but it is not reproducible as of now.
|
BhaveshHeliconia
left a comment
There was a problem hiding this comment.
Functional review LGTM!
|
Thanks for the review and the approval, @BhaveshHeliconia! On reproduction: the key trigger is the acting user not having read access to the matching duplicate partner. Multi-company (your companyA/companyB steps) is one clean way to hit it; a record rule that hides the existing partner from the current user (e.g. a salesperson restricted to their own contacts) is another. In either case, before this PR the same-email banner would compute the match as superuser and then render a link to a record the user can't read, raising the raw On the |
Summary
partner_email_duplicate_warnshows an on-change banner listing other partners that share the same email, each rendered as a clickable link. The matching partners are computed withcompute_sudo, so the banner could list — and link to — records the current user is not allowed to read. Clicking such a link (or, depending on the view, merely rendering it) raises the standard OdooAccessErrordialog, with no explanation of why the record is off-limits.This makes the banner access-aware: it links only to duplicates the acting user may actually read, and summarises the rest as a count instead of leaking links to forbidden records.
Changes
_compute_same_email_partner_idsnow filters the matched partners through the acting user's read access (_filtered_access("read")), sosame_email_partner_idsonly ever contains readable records.same_email_inaccessible_count: the number of same-email partners the user cannot read.same_email_inaccessible_countis set, a short message noting that N additional record(s) the user cannot access also use this address.Behavior notes
AccessErroris raised by the banner anymore; unreadable duplicates are surfaced as a count rather than a link.Tests
Adds
test_partner_duplicate_inaccessible: a duplicate hidden from the acting user by a record rule is counted insame_email_inaccessible_count, is not present insame_email_partner_ids, and reading the computed fields raises noAccessError.