Vauxoo / odoo

Fork of Odoo (formerly OpenERP). [This project is not publically mantained just born for internal usage with some little patches] go to official repository on github.com/odoo/odoo
https://www.odoo.com
Other
9 stars 9 forks source link

[IMP] base: allow configure models that can be deleted in partner merging #575

Open fernandahf opened 9 months ago

fernandahf commented 9 months ago

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

fernandahf commented 9 months ago

For record:

PR to Odoo:

https://github.com/odoo/odoo/pull/148387