[IMP] base: allow configure models that can be deleted in partner merging #575
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.
Description of the issue/feature this PR addresses:
The method
_update_reference_fields
is handling PSQL errors in the case in the middle of updating something fails and it's deleting indiscriminately the records involved presuming that PSQL error is always a unique violation, but can occur any PSQL error, so this change is allowing configure what models can be deleted in a unique violation if the models are not defined, it's working as currently, otherwise, it's validating the model and raising an error in case model is not in allowed ones.Current behavior before PR:
When a merge occurs, if there is a PostgreSQL error in updating reference fields, the records involved are deleted.
Desired behavior after PR is merged:
When a merge occurs, if there is a PostgreSQL unique violation error in updating reference fields and the parameter is
base_partner_merge.models_allowed_to_unlink
is configured, if records involved are in allowed models to delete, then delete them, otherwise raise an error to the user can review at detail.OPW: Pending