Party duplication

Rational

It is quite common to have duplicated parties. Even if there are custom checks that tries to avoid such cases, there is no solution that guarantee at 100% that no duplicates will ever exist.
So it is needed to have a way to manage such duplication.

Proposal

A wizard is used to replace all references (Many2One and Reference fields) to one party by another one. The replacement must be done at SQL level to avoid to trigger any validation or work-flow but the an history record must be created for historized model.
The wizard should also re-link the addresses and contact mechanism to the new party and mark them inactive.
For other fields like categories, it should create new entries for the missing values.
The replaced party will be marked as inactive to avoid new usage.
The wizard could have some comparison checks that will trigger a warning if both party fields does not match. This will avoid mistakes.
The replacement could be stored in a model to let the party administrator to follow the history.
The reference fields should be explicitly defined, here is a partial list:

  • Account Move Line: party
  • Invoice: party
  • Account Payment: party
  • Account Statement: party
  • Carrier: party
  • Company: party
  • Employee: party
  • Product Supplier: party
  • Project work: party
  • Purchase: party
  • Sale: party
  • Sale Opportunity: party
  • Drop Shipment: party
  • Shipments: party

Implementation

https://bugs.tryton.org/issue5820

So IIUC this list should be extendable by other modules, so each module adding a party field must be responsible of adding it into the deduplication, list if needed.

Would a “is an alias of” relation between two parties do the the trick too ?

No because the receivable, payable amount should be correctly computed and also one could expect that the relates will work correctly.

Indeed I think it is simpler to just update the address to be linked to the new party and mark it as inactive.

With this design, it is no more needed to update address fields.