Skip to content

FIX category links cleanup before deleting commercial objects#38970

Open
mapiolca wants to merge 6 commits into
Dolibarr:23.0from
mapiolca:23.0-fix-delete-propal-with-category
Open

FIX category links cleanup before deleting commercial objects#38970
mapiolca wants to merge 6 commits into
Dolibarr:23.0from
mapiolca:23.0-fix-delete-propal-with-category

Conversation

@mapiolca

Copy link
Copy Markdown
Contributor

FIX Category links cleanup before deleting commercial objects

Delete native category links before deleting categorized commercial objects to avoid foreign key constraint failures.

This fixes deletion of:

  • customer proposals linked to categorie_propal
  • supplier proposals linked to categorie_supplier_proposal
  • supplier invoices linked to categorie_supplier_invoice

It also removes the incorrect supplier invoice cleanup against categorie_invoice, which belongs to customer invoices.

mapiolca added 6 commits June 23, 2026 09:42
Ensure category links are removed when deleting proposals, supplier proposals and supplier invoices by adding DELETE queries for categorie_propal, categorie_supplier_proposal and categorie_supplier_invoice and handling DB errors. Reorganize supplier invoice delete logic so category cleanup occurs before discount freeing. Update PHPUnit tests (PropalTest, SupplierProposalTest, FactureFournisseurTest) to create a category link, assert deletion of the category row after object delete, and require the categorie class.
Remove the surrounding if(!$error) guard so the DELETE from categorie_supplier_invoice runs regardless of prior errors. This ensures linked categories are always cleaned up for the supplier invoice; preserved existing error handling to record DB failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant