[19.0][ADD] portal_address_parent_protection - #1215
Open
MarcGForgeFlow wants to merge 1 commit into
Open
Conversation
Prevent a portal user from renaming their parent company, from editing the company record itself during checkout, and from overwriting the company address when saving their own.
MarcGForgeFlow
force-pushed
the
19.0-add-portal_address_parent_protection
branch
from
August 20, 2026 11:36
058812d to
d2437c5
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.
A portal user who is a child contact of a company can rename that company and overwrite its address from the frontend address forms. This module closes the three paths that allow it.
The company gets renamed because
_create_or_update_address()assignsparent_company.name = company_name, and_validate_address_values()dropscompany_nameonly when the edited address is not the current customer's own record. A contact therefore renames its parent company through its own address form.The company record itself becomes editable because
_can_be_edited_by_current_customer()compares the edited record against_get_current_partner(), whichwebsite_saleoverrides to return the customer of the current cart. When something sets the cart customer to the parent company - OCA'swebsite_sale_partner_sale_contactdoes exactly that - core seesself == current_partnerand grants the portal user full edit rights on the company during checkout: name, email, phone and address, in a single submission. This module anchors the check on the partner of the logged in user instead. Public users are left to the core behaviour, since their own partner is the public one while the cart may legitimately point to the address they just created.The company address gets overwritten because a contact of type
contactshares its parent's address, so_fields_sync()propagates any address change up to the parent (res.partner, section "To UPSTREAM"). A portal contact saving their personal address replaces the address of the whole company. This is now skipped when the write comes from a portal user. Writes includingparent_idare left untouched, as core is then expected to initialise the address of the company the contact is being attached to.To reproduce, with
website_saleandwebsite_sale_partner_sale_contactinstalled:/my/account, saving your own street also changes the company address.Internal users keep the core behaviour in both cases. See the ROADMAP for the
website_event_salelimitation.