[19.0][ADD] portal_address_copy_on_edit - #1217
Open
MarcGForgeFlow wants to merge 1 commit into
Open
Conversation
Create a new address when a portal customer edits one of their invoice or delivery addresses, instead of rewriting the address the documents already issued were issued with. The edited address is kept, not archived.
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.
When a portal customer edits one of their invoice or delivery addresses, core rewrites the partner in place. The documents already issued with that address - confirmed sale orders, posted invoices, delivery notes - then display an address they were never issued with, and the previous value is lost.
This module creates a new address instead, and leaves the edited one untouched. It hooks into
CustomerPortal._create_or_update_address()and drops the partner being edited, so core follows its own creation path: the address is completed and attached to the commercial partner by_complete_address_values(), andwebsite_salerepoints the cart to the record returned by the call. No core logic is duplicated.Two cases are deliberately left alone. The customer's own contact record is edited in place, since it is not an invoice or delivery address but their own data, and replacing it would detach them from their own documents. A form saved without changes is not copied either, so opening an address and saving it untouched leaves no duplicate behind.
The superseded address is kept rather than archived. Whether an address is still wanted is a business decision, and it is noted in the ROADMAP together with the
only_servicescart limitation.To reproduce, as a portal user in My Account > Addresses, edit a delivery or billing address that a confirmed order already uses and save it. Without the module the order shows the edited address; with it, both addresses are listed and the order still points at the original.
Tested with 5 tests on a database with only
portaland its dependencies installed.